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

GridViewComboBoxColumn how to fire event if specific value is selected

1 Answer 17 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Jon
Top achievements
Rank 1
Jon asked on 30 Oct 2012, 11:41 PM
 Hi.. I have a GridViewComboBox.. I need to fire an messagebox if the user selects a specific value.
How can I do this?
thanks again


      <telerik:GridViewComboBoxColumn x:Name="cmbCategory" Header="Contact Category" DataMemberBinding="{Binding CallActivity_category_Id}" Width="140" DisplayMemberPath="CallActivity_category_title" telerik:TextSearch.TextPath="CallActivity_category_title" 
                                        SelectedValueMemberPath="CallActivity_category_Id" />

1 Answer, 1 is accepted

Sort by
0
Yoan
Telerik team
answered on 05 Nov 2012, 06:30 AM
Hi Jon,

 In order to achieve your goal I suggest you to subscribe to the RadComboBox's SelectionChanged event like so:

public MainWindow()
       {
           InitializeComponent();
 
           this.AddHandler(RadComboBox.SelectionChangedEvent, new System.Windows.Controls.SelectionChangedEventHandler(OnSelectionChanged));
       }
 
 
       private void OnSelectionChanged(object sender, System.Windows.Controls.SelectionChangedEventArgs e)
       {
           string selectedItem = string.Empty;
           if (e.RemovedItems.Count>0 && e.AddedItems.Count > 0)
           {
               selectedItem = e.AddedItems[0].ToString();
               txtSelectedValue.Text = selectedItem;
               MessageBox.Show(selectedItem);
           }
       }

For your convenience I have attached prepared a sample project. Please find it attached.

Greetings,
Yoan
the Telerik team

Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Tags
GridView
Asked by
Jon
Top achievements
Rank 1
Answers by
Yoan
Telerik team
Share this question
or