This is a migrated thread and some comments may be shown as answers.

Open ComboBox on begin cell edit

7 Answers 124 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Terry Foster
Top achievements
Rank 1
Terry Foster asked on 28 Jul 2010, 02:39 PM
Hi,

What's the simplest way to get the ComboBox of a GridViewComboBoxColumn cell to drop down as soon as it goes into edit mode?

Thanks,
Terry

7 Answers, 1 is accepted

Sort by
0
Tsvyatko
Telerik team
answered on 29 Jul 2010, 10:31 AM
Hi Terry Foster,

You can achieve this by defining Editor style and setting IsDropDownOpen property to true. Please check the attached project as reference.
If you have any other issues or questions do not hesitate to contact us.


Sincerely yours,
Tsvyatko
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Terry Foster
Top achievements
Rank 1
answered on 29 Jul 2010, 02:34 PM
Your demo works great, but when I attempt to do the same thing in my application, I get an AccessViolationException ("Attempted to read or write protected memory. This is often an indication that other memory is corrupt.").  Do you have any ideas why this might be happening?

Thanks,
Terry
0
Tsvyatko
Telerik team
answered on 02 Aug 2010, 09:57 AM
Hi Terry Foster,

This issue could result of different factors. While I cannot give straight answer what is causing the issue I can give some directions what could be the cause:

- malformed XAML
- Running SL3 app and applying implicit styles
- Currupted Silverlight environment

I can also suggest you check this hyperlink for additional information:
http://forums.silverlight.net/forums/p/178858/435729.aspx


All the best,
Tsvyatko
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Terry Foster
Top achievements
Rank 1
answered on 06 Aug 2010, 02:20 AM
It took me quite a while, but I finally tracked down the issue.  I basically want two non-default behaviors for grid combo boxes:

1. Automatically open on begin cell edit.
2. Automatically end cell edit on item select (or close drop down).

The first item does indeed work fine with an editor style as you prescribed.  However, now it conflicts with how I was achieving the second item.  I was doing it by adding an event handler to the grid view for the RadComboBox.SelectionChangedEvent and doing the following:

 

 

private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)

 

{

 

 

    if (((RadComboBox)e.OriginalSource).IsDropDownOpen)

 

        CurrentCell.CommitEdit();

}


And this was working fine until I implemented the first item.  But I can see how this approach for the second item is probably not the best.  However, I cannot discover another way to do it.  Any suggestions?

Thanks,
Terry
0
Tsvyatko
Telerik team
answered on 09 Aug 2010, 02:33 PM
Hello Terry Foster,

Could please post the way you are subscribing to the event.

Greetings,
Tsvyatko
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Terry Foster
Top achievements
Rank 1
answered on 09 Aug 2010, 02:50 PM

My code for opening the combo box:

 

 

 

Style editorStyle = new Style(typeof(RadComboBox));

 

editorStyle.Setters.Add(

 

new Setter(RadComboBox.IsDropDownOpenProperty, true));

 

 

 

 

comboBoxColumn.EditorStyle = editorStyle;

 


My code for ending cell edit:

this.AddHandler(RadComboBox.SelectionChangedEvent, new SelectionChangedEventHandler ComboBox_SelectionChanged), true);

 

 

 

private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)

 

{

 

 

    if (((RadComboBox)e.OriginalSource).IsDropDownOpen)

 

        CurrentCell.CommitEdit();

}

 

 

 


The combination of these two causes the 'AccessViolationException'.  Regardless of the exception, I don't think I can do it this way - the 'SelectionChanged' event is raised during the process of dropping down the combo box.  Not good.  Please help me figure out a way to get the two behaviors I want.  Ideally, I'm thinking I just need an event I can hook into for when the drop down is closing (which I don't think currently exists) and use that instead of hooking into the SelectionChanged event.

Thanks,
Terry

0
Tsvyatko
Telerik team
answered on 12 Aug 2010, 01:30 PM
Hi Terry Foster,

Based on the latest request, I have modified the sample to enable the required functionality. The best way in this case is to inherit the GridViewCheckBoxColumn, extending the functionality that we need. Please have a look at the attachment and let know if this works for you.

Sincerely yours,
Tsvyatko
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
Tags
GridView
Asked by
Terry Foster
Top achievements
Rank 1
Answers by
Tsvyatko
Telerik team
Terry Foster
Top achievements
Rank 1
Share this question
or