添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
I have a combo box column with in the grid and i need  an event for that combo box value changed .
I am unable to register a selection changed event for telerik:GridViewComboBoxColumn.
Suggest me how to do that.
Thanks,
Swathi.

You may add a handler for the SelectionChanged event as follows:

this.RadGridView1.AddHandler(RadComboBox.SelectionChangedEvent, new SelectionChangedEventHandler(OnSelectionChanged));
private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
// TODO: Implement this method
throw new NotImplementedException();
All the best,
the Telerik team Browse the videos here>> to help you get started with RadControls for WPF
Thanks for the immediate response.I am able to register and use the event now.But i have few more queries.
1.Can i register the event for a particular column in a grid.right now i am putting a condition within the event.
2.This event is being called while loading also,which i think is not valid.Can u answer this?
Thanks in advance
Hello Swathi,

You need to define a condition in the OnSelectionChanged method if you want to fire the event only for a particular column. For example:

private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
//First approach:
var cell = (e.OriginalSource as RadComboBox).ParentOfType< GridViewCell >();
if (cell != null && cell.Column.UniqueName == "MyUniqueName")
//Second approach:
RadComboBox comboBox = (RadComboBox)e.OriginalSource;
if (comboBox.SelectedValue == null || comboBox.SelectedValuePath != "Code") // we take action only if the continent combo is changed
As for your second question, indeed the event is fired while loading and so far this is the expected behavior.

Greetings,
the Telerik team Browse the videos here>> to help you get started with RadControls for WPF

Please could you also provide a sample in VB, your converter is next to useless when dealing with events
Cheers
I have no idea how to implement the following in VB:
this.RadGridView1.AddHandler(RadComboBox.SelectionChangedEvent, new SelectionChangedEventHandler(OnSelectionChanged));
The converter gives you this:
Me.RadGridView1.[AddHandler](RadComboBox.SelectionChangedEvent, New SelectionChangedEventHandler(OnSelectionChanged))
As with all addhandler conversions it is wrong, I have worked out how to modify a normal handler using the address of function but I cannot work out the syntax for how to handle one that is bound to a grid, it comes up with errors like, cannot use a lamda expression, must use addressof and radcombobox has no such event..
Cheers
Hadn't seen that blog post but I still get this error:
Error 3 Method 'Private Sub comboSelectionChanged(sender As Object, e As Telerik.Windows.RadRoutedEventArgs)' does not have a signature compatible with delegate 'Delegate Sub SelectionChangedEventHandler(sender As Object, e As Telerik.WinControls.UI.SelectionChangedEventArgs)'. C:\TFS_Trunk\BM Pallets\EMU\dashboard\admin\ucAdminAddresses.xaml.vb 29 101 dashboard
My other issue here is that I have spent countless hours as a VB developer trying to find work arounds to the c# code samples and documentation. Surely you as a company selling these controls for the same price as the c# users should provide equal documentation for both instead of making us VB users scrounge around in blog posts hoping that someone else has had the same issue previously. Just today I have wasted 2 hours on this and I've been having these same issues for around 3 years now, it equates to 'days' lost...!
Thank you for sharing your feedback.
For the VB programmers we offer this online converter . For the purpose of converting entire solutions, you can also consider using Instant VB Converter .
Also, as you run the WPF demos , the C# code can be converted into VB.NET code on demand (choosing the VB.NET tab for the code behind files).
Regards,
Dimitrina
Telerik 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 Feedback Portal and vote to affect the priority of the items

I'm trying to add selectioin changed event in my GridViewComboboxColumn.

But, AddHandler does not exist.

I'm using Telerik UI for WinForms R2 2017 SP1.

Hello AungKo,
The AddHandler () method is part of the WPF framework. If you need to subscribe to a handler in WinForms I would suggest you take a look at the MSDN docs.
Also, if for any questions related with Telerik UI for WinForms may I ask you to post your question in the WinForms forum or via the support ticketing system.
Regards,
Martin Ivanov
Progress Telerik Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin , a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.

I found this information helpful .. But I was wondering if it was possible to add the Even handler in XAML

Thanks

Hello Michael,
The event handler cannot be attached in XAML in this scenario. This is because the column doesn't expose the corresponding event. The AddHandler() method is used to globally attach the handler to all selector elements that expose SelectionChanged event.
An alternative approach to subscribe to the SelectioChanged event is to create a custom combobox column and override its CreateCellEditElement. There you can get the RadComboBox element and subscribe to its SelectionChanged event. Then raise a new custom event that you can use. Here is an example in code:
public class CustomGridViewComboBoxColumn : GridViewComboBoxColumn
public event EventHandler<SelectionChangedEventArgs> SelectionChanged;
public override FrameworkElement CreateCellEditElement(GridViewCell cell, object dataItem)
var comboBox = (RadComboBox) base .CreateCellEditElement(cell, dataItem);
comboBox.SelectionChanged += OnComboBoxSelectionChanged;
return comboBox;
private void OnComboBoxSelectionChanged( object sender, SelectionChangedEventArgs e)
if (SelectionChanged != null )
SelectionChanged( this , e);
< telerik:RadGridView.Columns >
< local:CustomGridViewComboBoxColumn SelectionChanged = "CustomGridViewComboBoxColumn_SelectionChanged" />
</ telerik:RadGridView.Columns >
Regards,
Martin Ivanov
Progress Telerik Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin , a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.