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

How to add DoubleClick event handler?

10 Answers 437 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Przemyslaw
Top achievements
Rank 1
Przemyslaw asked on 18 Mar 2010, 10:54 AM
Hi,

So far I have been using the MouseLeftButtonDownEvent to handle clicks within a gridview (for opening detail windows). Since Q1 2010 apparently supports DoubleClick event, I really would like to switch to that. This is what I have been using:
//In Constructor  
AddHandler(GridViewCell.MouseLeftButtonDownEvent, new MouseButtonEventHandle(Cell_Clicked), true);  
 
//Handler  
private static void Cell_Clicked(object sender, MouseButtonEventArgs e)   
{  
    // ... Displaying details window  

And this is something that I would like to use:
//In Constructor  
AddHandler(GridViewCell.CellDoubleClickEvent, new SomeEventHandler(Cell_DoubleClicked), true);  
 
//Handler  
private static void Cell_DoubleClicked(object sender, SomeEventArgs e)     
{  
    // ... Displaying details window  

However, what is the delegate EventHandler type that can/should be used here? What is the EventArgs type?

regards, Przemek

10 Answers, 1 is accepted

Sort by
0
Vlad
Telerik team
answered on 18 Mar 2010, 11:02 AM
Hello,

Please check this demo for more info:
http://demos.telerik.com/silverlight/#GridView/ClickEvents

All the best,
Vlad
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
Przemyslaw
Top achievements
Rank 1
answered on 18 Mar 2010, 11:26 AM
Hi,

thanks, I have started implementing what I have seen in the sample and I am experiencing the following compile time errors:

Error 1 The best overloaded method match for 'System.Windows.UIElement.AddHandler(System.Windows.RoutedEvent, System.Delegate, bool)' has some invalid arguments C:\Projects\Admin\Network_Admin\Network_Admin\content\administration\players\Player_AllPlayers_GridView.xaml.cs 30 13 Network_Admin

Error 2 Argument 1: cannot convert from 'Telerik.Windows.RoutedEvent' to 'System.Windows.RoutedEvent' C:\Projects\Admin\Network_Admin\Network_Admin\content\administration\players\Player_AllPlayers_GridView.xaml.cs 30 24 Network_Admin

for this call:
AddHandler(GridViewCell.CellDoubleClickEvent, new EventHandler<RadRoutedEventArgs>(Row_DoubleClicked), true); 

Apparently AddHandler() method is expecting System.Windows.RoutedEvents and the CellDoubleClickEvent is of Telerik.Windows.RoutedEvent type.

What is wrong here?

Przemek
0
Damian Slee
Top achievements
Rank 1
answered on 18 Mar 2010, 04:15 PM
i am also getting a compile error expecting System.Windows.RoutedEvents?

the sample works, so is the example code wrong?

thanks
damian
0
Pavel Pavlov
Telerik team
answered on 19 Mar 2010, 02:55 PM
Hi guys,

I am attaching a sample project for your reference. Please check if you have the right "using" directives.

Best wishes,
Pavel Pavlov
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
Przemyslaw
Top achievements
Rank 1
answered on 19 Mar 2010, 04:46 PM
Thanks,

I have downloaded your sample. It compiled and then I didn't get anything on double click. As if the event didn't register. I am using Visual Studio 2010 RC.

In my project I think that I have all the proper references and usings. My AddHandler method still cannot be resolved with the telerik's extension method (see image). Of course I have a little different structure. Maybe that is the reason.

Przemek
0
Damian Slee
Top achievements
Rank 1
answered on 19 Mar 2010, 05:04 PM
adding this fixed it for me.

using Telerik.Windows;
0
Accepted
Stefan Dobrev
Telerik team
answered on 23 Mar 2010, 02:31 PM
Yes,

This using is required in order for the C# compiler to resolve our extension method. Also note that you have to use this.AddHandler(...) or RadGridViewInstance.AddHandler(...) because this is an extension method.

Best wishes,
Stefan Dobrev
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
Przemyslaw
Top achievements
Rank 1
answered on 24 Mar 2010, 08:21 AM
Thanks Stefan.

That was it. The Extension was not picked up until I used *this* keyword. Now, the doubleclick event is working as it should be.

regards, Przemek
0
codeputer
Top achievements
Rank 2
answered on 23 Apr 2011, 09:50 PM
How do you determine the RadGridViewColumn that was double clicked - in some cases the grid will go into edit mode if the column is not read only, and I want to avoid opening the detail form.

Why does the Grid not mark the event has handled if the double click goes into edit mode?

Thanks,
Richard
0
Pavel Pavlov
Telerik team
answered on 27 Apr 2011, 01:31 PM
Hi Richard,

Yo can identify the column that was double clicked the following way :
this.AddHandler(GridViewCell.CellDoubleClickEvent, new EventHandler<RadRoutedEventArgs>((sender,args)=>
                {
                    MessageBox.Show("Column :" + ((GridViewCell)args.OriginalSource).Column.UniqueName);
                }
                ));


Greetings,
Pavel Pavlov
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
Przemyslaw
Top achievements
Rank 1
Answers by
Vlad
Telerik team
Przemyslaw
Top achievements
Rank 1
Damian Slee
Top achievements
Rank 1
Pavel Pavlov
Telerik team
Stefan Dobrev
Telerik team
codeputer
Top achievements
Rank 2
Share this question
or