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

GridViewComboBoxColumn - Selection change?

8 Answers 342 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 01 Dec 2009, 05:27 PM
Hi..
How do you handle the selection change of a GridViewComboBox? What event should I use? I Don't see a selectionchange.
When the value changes I want to populate other columns in the grid with portions of the data. Any idea how I can do that?
thanks in advance

8 Answers, 1 is accepted

Sort by
0
Pavel Pavlov
Telerik team
answered on 04 Dec 2009, 03:00 PM
Hi Jon,

The attached example demonstrates a way to handle selection changes  combo box.
Let me know if you find a trouble adapting this to your project.

Sincerely yours,
Pavel Pavlov
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
0
Jon
Top achievements
Rank 1
answered on 04 Dec 2009, 04:04 PM
thanks again
0
Paul Dyksterhouse
Top achievements
Rank 1
answered on 03 Feb 2010, 07:50 PM
There is a bug in the provided example. The Event fires when the cell enters edit mode not just when the selection actually changes.
0
Pavel Pavlov
Telerik team
answered on 04 Feb 2010, 10:27 AM
Hi Paul Dyksterhouse,

Thanks for mentioning that. Actually the ComboBox does not exist until the cell enters edit mode. It is created on the fly ( in order to keep memory low and performance high) .

So when the Cell enters edit mode , the combo is created, and the selected value is being set to the value of the owning cell . This of course raises the selection changed event .

Although this is expected behavior , if this causes certain  complications  - we may think of a workaround for the certain scenario.

Regards,
Pavel Pavlov
the Telerik team

Watch a video on how to optimize your support resource searches and check out more tips on the blogs.
Follow the status of features or bugs in PITS and vote for them to affect their priority.
0
Brian
Top achievements
Rank 1
answered on 28 Feb 2013, 01:05 PM
If anyone else is interested in the 'workaround' mentioned, take a look at the e.RemovedItems logic in the following thread.

http://www.telerik.com/community/forums/wpf/gridview/combobox-selection-event-is-getting-fired-on-row-delete-row-add-into-datagrid.aspx

0
Alex R.
Top achievements
Rank 1
answered on 23 Oct 2013, 07:26 PM
Paul,

I have a grid with multiple combo boxes and I was wondering how to get the combo box name?

private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
    RadComboBox combo = (RadComboBox)sender;
 
    if (combo.Name == "Something")
    {
    }
}

Best regards,

Alex
0
Matt
Top achievements
Rank 1
answered on 24 Oct 2013, 05:23 PM
Trogdor,

I think (I have not tested this) you might actually have to do something like:
string name = comboBox.Name;
if(name.Equals("SomeName"){ }

before you can do the comparison.  I would have to test that to be sure but for some reason I thought you had to actually get the name before you did the compare else it would never work out....not sure why I feel like I tried this before...
0
Yoan
Telerik team
answered on 28 Oct 2013, 12:25 PM
Hello ,

You can set the UniqueName property of your ComboboxColumn:

<telerik:GridViewComboBoxColumn DataMemberBinding="{Binding CountryId}"
            UniqueName="Country"
            SelectedValueMemberPath="Id"
            DisplayMemberPath="Name" />

then you can check CurrnetColumn's name along with the RemoveItems.Count:

this.AddHandler(RadComboBox.SelectionChangedEvent, new System.Windows.Controls.SelectionChangedEventHandler(OnSelectionChanged)); 
       .
       .
       .

private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (e.RemovedItems.Count > 0 && (e.Source as RadGridView).CurrentColumn.UniqueName == "Country")
            {
                //your code here
            }
        }

I hope this helps.

Regards,
Yoan
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Jon
Top achievements
Rank 1
Answers by
Pavel Pavlov
Telerik team
Jon
Top achievements
Rank 1
Paul Dyksterhouse
Top achievements
Rank 1
Brian
Top achievements
Rank 1
Alex R.
Top achievements
Rank 1
Matt
Top achievements
Rank 1
Yoan
Telerik team
Share this question
or