
Is this possible to add Double click event on row of RadGridView?
if it is posssible then pls give such example .. because there no such out of box event available for that..
yes , it may be possible using "DependancyProperty" but don't know exact.
Pls help me out..
Thanks,
Ganesh
58 Answers, 1 is accepted

I'm looking for the same thing. Any ideas?
Regards, S

Did you mean you are tring to attach event handler on gridview's row?
Please look the code below :
(this.GridView as RadGridView).AddHandler( |
GridViewCell.MouseDoubleClickEvent, |
new EventHandler<Telerik.Windows.RadRoutedEventArgs>(this.OnDoubleClick)); |
private void OnDoubleClick(object sender, Telerik.Windows.RadRoutedEventArgs e) |
{ |
.....your logic |
} |
And you shoud add Telerik.window.controls.dll to your project. hope this help
Regards,
Eum

Thx.
Regards S


Please find attached a solution that shows how to handle a double click event of GridViewRow.
Best wishes,Yavor Georgiev
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.


Thank you for your example. I have implemented in my project and the double click works fine. I use the DoubleClick event to open a RadWindow but I also have a context menu on the grid.
My problem is that if a user single Left-clicks on a row and immediately right-clicks to get the context menu, the DoubleClick event gets fired. This results in the context menu and the RadWindow being shown.
This is not my desired action. Is there any way of stopping this happening? i.e. click on row, then a right click should just bring up the context menu.
Thanks in advance
Mark.
You might wish to implement a "custom" double click event like in the example I have posted, which tracks only the left mouse button, not both. Please inspect the solution and let me know if you need any help.
Regards,Yavor Georgiev
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.

myGridView.RowActivated+=
new EventHandler<RowEventArgs>(myGridView_RowActivated);
That is true most of the time - a double-click on the row does trigger the RowActivated event, but so does RadGridViewCommands.ActivateRow and a number of other actions, depending on user customization.
Regards,Yavor Georgiev
the Telerik team

Using the example project listed above, how can i differentiate between the double click on a GridViewRow and a GridViewHeaderRow?
There are two ways: check if the row is of type GridViewHeaderRow, GridViewNewRow or GridViewFooterRow and check if the row's Item property is null. Only GridViewRow contains a data item, so it's Item property will never be null.
All the best,Yavor Georgiev
the Telerik team

Thanks!
Troy
That's the general idea of routed events in Silverlight and WPF - they climb up the visual tree so that in the end the control that handles the event gets hit whenever that event fires for any control below it in the visual tree. Handling LeftMouseButtonUp on your GridView or even UserControl is fine. You just have to check if the element in which the event originates is the one you need and only then take action.
Besides, if you try to manually attach handlers to row objects, this will play merry hell with virtualization.
Yavor Georgiev
the Telerik team

You've resolved all my problems...
Thank you.

Your solution is working but I only see this as a workaround to the problem.
If I want to use your code, I will have to duplicate it all over the place or build a wrapper user control around the RadGridView.
Why don't you add a Click and a DoubleClick event (with the clicked cell / row / column) to the RadGridView itself? Click and DoubleClick are not extravagant features for a grid... in fact; they are built-in for almost every grid component since the last decade.
Have you seen this demo?
Best wishes,Vlad
the Telerik team

Yavor solution is working but as I mentionned before, it's not perfect, esspecially when you need to reuse the code all over the place.
As far as I can see no usage of RoutedEvent in this demo. Can you clarify?
All the best,Vlad
the Telerik team

Private Sub OnCellDoubleClick(sender As Object, args As RadRoutedEventArgs)
However, the error is raised in this line of code:
Me.RadGridView1.[AddHandler](GridViewCellBase.CellDoubleClickEvent, New EventHandler(Of RadRoutedEventArgs)(AddressOf OnCellDoubleClick), True)
The error is on the first parameter (GridViewCellBase.CellDoubleClickEvent) wich is a System.Windows.RoutedEvent
Have you copied the usings as well?
Greetings,Vlad
the Telerik team

In this case everything should work as expected - as on our example.
All the best,Vlad
the Telerik team

I did find out what was the problem. A using statement is missing in the example source code:
using Telerik.Windows;
If you add this line, everything works as expected.
An other option would be to call Telerik.Windows.DependencyObjectExtensions.AddHandler directly instead of using it as an extension. That way, the using Telerik.Windows; line is not required.

// handling the MouseDoubleClick event of the RadGridView
void
OnGridMouseDoubleClick(
object
sender, MouseButtonEventArgs e)
{
FrameworkElement originalSender = e.OriginalSource
as
FrameworkElement;
object
oTest = sender.GetType();
if
(originalSender !=
null
)
{
var cell = originalSender.ParentOfType<GridViewCell>();
if
(cell !=
null
&& cell.Column.UniqueName ==
"CaseId"
)
{
...
But, of course that limits clicks to the specific cell in order to get its value. Is there a way to get that value on a click on any cell in the row?
You could try using CurrentCellChanged event which will be raised as you click on cells.
Best wishes,
Milan
the Telerik team


Is there any chance this is going to be added in the near future to a Q11 update?
I created a small project illustrating the idea from this example. Still, the event is fired correctly for RadGridView in the RowDetails as well. Does this scenario correspond to yours ? Can you reproduce the same behavior on the attached project ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

I'm trying to use this demo code but it simply does not work in my application, the event does not get fired
It's very frustrating that something so basic as double clicking a row in a grid is so difficult to do on the radgridview.
Actually, we are aware of this issue and it has already been resolved. The fix will be available in our next internal build.
Thank you for your feedback.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Actually, the behavior of double click event and its usage should be the same as those for Silverlight 4.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

Thanks
Prakash

I'm using RowActivated event for now, but it was my understanding that the Q1 2012 version for SL5 projects would have the DoubleClick event ... it doesn't appear to have any such event?
Your demo code is interesting, but it does cause other problems requiring additional code and work arounds ... definitely not ideal for RAD (rapid application development).
Is there any reason why you folks are not adding this feature since it clearly is something many of us want?
Rob
The double click in Silverlight 5 is actually MouseLeftButtonDown + e.ClickCount.
Regards,Vlad
the Telerik team

Thanks, didn't know that ... will look into using that.
Rob.

VB.Net
Private Sub dgObjects_RowActivated(sender As System.Object, e As Telerik.Windows.Controls.GridView.RowEventArgs) Handles dgObjects.RowActivated
If Not dgObjects.SelectedItem Is Nothing Then
MessageBox.Show("test")
End If
End Sub

I fail to see how this has anything, what so ever, to see with double click???
Care to explain?
Best Regards,
Peter


It would be great if you specify your exact requirement and the scenario that you want to implement. Why working with RowActivated event is not appropriate for your ? What is the behavior that you want to get ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

I've been promised time and again "this is coming". What is taking so long?
I know frustration but this is getting rediculous.
I might be missing something here, but why following any of the suggestions above is not suitable for you ? You can work with RowActivated event, CellDoubleClick, MouseLeftButtonDown + e.ClickCount. Could you clarify what is the scenario that you want to accomplish, but still cannot with any of those approaches ?
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Problem with RowActivated is that if the row is already activated, then no event fires, so then we have to add code to deal with that situation. For many of us that buy/subscribe to 3rd party tools is so that our work load is reduced. I share Chris's frustration, but I also realize there is not much point in doing more work (by Telerik) on a technology that has ended it's life and the new "fad" is HTML5.
SL5 is better (solves more end user problems) than HTML5 but neither are as good as Windows Forms in terms of ease of application development and ROI. The biggest problem with SL5 is that much of it doesn't have adequate documenation (including you folks on your products). Why I mention this on a "DoubleClick" event is because there are developers such as myself that don't have the time and we expect 3rd party tools to save us time, not increase our time. In fact, the entire point of 3rd party tools is to save time and accomplish tasks that we would have to code ourselves. Rather than a company hirings a programmer to do exclusive UI work we buy 3rd party tools, such as Telerik ... it's much more cost effective.
Sooo, when we see what we consider basic features missing and have to keep coding work arounds or adding more complex code to deal with a situation we feel we paid for in a 3rd party tool, it gets frustrating.
I'd even venture to guess that the smaller the company the more likely they'll look at 3rd party tools ... and those tools need to help us get things done faster. And lets face it, when it comes to code bloat SL is certainly a top 10 for excessive code. But there again, many products from Microsoft seem to be focused on endless layers of abstraction, to the point where it's so difficult to manage the abstraction where one small change can cause massive application wide bugs ... I diverge ... but I've been around for a while (30+ years) and today's application development seems to be more a game of who can abstract the most and get less actual work done. Technologies change so frequently that all the effort that's gone into re-use and abstraction is nullified (wasted even) ... just like SL ending.
Anyway, I realize it's unlikely we'll see a RowDoubleClick, but I can appreciate the need for one.
Rob

Hello Rob/Chris and everyone else who is ranting...
Here's how I send the double click to my view model (using MVVM Light).
This works on an already selected row/column mentioned in a previous post and it's easy to implement.
public ViewDashboard()
{
InitializeComponent();
this.radgridview1.AddHandler(GridViewCellBase.CellDoubleClickEvent, new EventHandler<
RadRoutedEventArgs
>(OnCellDoubleClick), true);
}
private void OnCellDoubleClick(object sender, RadRoutedEventArgs e)
{
if (e.OriginalSource.GetType() == typeof(GridViewCell))
{
AppMessages.GridDoubleClickEvent.send(e);
}
}
It's not a workaround, it is using the tools that have been given.
If you are driving a car and your sat nav sends you the wrong way, you have a choice.
1. Find another way or
2. Sit in the car, bash the steering wheel, kick the dog and and scream at passers by.
I choose to implement a solution and move on!
No offence intended of course, but I fail to see why a developer wouldn't implement such a simple solution. If something better comes along then great, but since posting to this thread over a year ago I am astonished it is still going!
Here to help and happy to.
Mark.
PS: Screaming at the wife often helps!

Telerik as always please implement a .RowDoubleClick as soon as it can be included in a release. We plan to use Silverlight for sometime and will move to another technology when it matures. The RadGridView improvements for SL5 have been HUGE so thank you for making those available.
HELP!!!

You forgot option #3
Fix the Nav so it doesn't send you to the wrong place
;)
Would love to know what "AppMessages" is about ... can't find any info on it and doesn't intellisense anywhere in my code??
Telerik folks are doing a good job, they just need some improvements to help use customers/developers get things done quickly.
Rob

Hi Rob
Yes, fix the Sat Nav, but screaming at passers by releases some tension. :-)
AppMessages is part of MVVM-Light (http://mvvmlight.codeplex.com/) and allows me (and you, should you implement it) to separate code from design. Highly recommended if you are working in a team where designers are involved.
I add the handler in the constructor and when it is fired, I pass 'RadRoutedEventArgs e' to my ViewModel and check for e.ClickCount to determine if a double click was raised by the UI. You don't have to do it this way of course, you can check for e.ClickCount in your code behind and act on it as normal.
Hope that helps, but I can elaborate if you want me to.
Regards
Mark
PS: Chris.. I am not sure what you are getting at by your reply. I am not part of Telerik, just a fan, so I can't magic a solution for you apart from what has been suggested in previous posts. Happy to help though if I can.


Think you're being a little dramatic, I'm not screaming at anyone. I've implemented a solution that works for me. I'm not in a position to set Telerik feature "priority" -- I don't have access to their customer data for feature improvements so I have no idea what is or isn't important.
Given the age of this thread, it is somewhat surprising that no such feature has been implemented, but NOT too surprising. SL is dead (in the sense it has no future upgrade path) and I'm sure Telerik are moving resources to HTML5 ... so I agree, it's unlikely we'll ever see a RowDoubleClick implementation.
I don't use MVVM, tried it, but found it too slow on the end user side, it was "pretty" on the development side, but my end users take priority. MVVM just wasn't good on ROI and didn't really provide any benefit to my end users/clients. I'm sure Mr. Martin Fowler had good intentions with MVC but my real world has demonstrated that for a truely good and fast application the designer (View side) has to get involved in the ViewModel (logic) because there are pratical performance limits. The basic premise that the user interface changes frequently really does NOT apply, in fact, most of my end users/client would MUCH RATHER the interface NOT change ... so implementing MVVM would be like building a Space Shuttle to go from your house to the grocery store ... when a simple cheap car will do :)
A good example of where MVVM would introduce a big performance hit ... suppose you define a UserControl that has a Button - Stack Panel - Image - TextBlock. You add some DependencyProperties to my UserControl to support a User access (security) ... say a User Logs in and their access rights are define by an EventType and an EventID (extracted from a database) ... make these a part of the UserControl. EventType and EventID are values used to match up with whatever the User has access to ... if the user has a record in a database with matching EventType and EventID the UserControl IsEnabled. In order to make this follow MVVM, the UserControl needs to be able to support IsEnabled (View) which is set by a return value from a web service (Model) that matches User, EventType, and EventID (ViewModel). If I have 40 instances of these UserControls on my Page then I have to make 40 individual web service calls IF I truely want to maintain MVVM ... web services are slow, just one more layer to getting data to an application (much slower than if it were possible to use SqlClient directly which you can't do in SL). Not doing the MVVM route, I could simply make ONE web service call that gathers up all the approprite data for the User for all 40 UserControls, cycle thru that data and match up each UserControl and set IsEnabled. This IS a much faster process but IS NOT MVVM.
As you know, web services are NOT fast (any time you add a layer, you slow things down) and they are Asynchronous which may seem great but more often than not other Controls need to wait for the population of one control before they can gather up the data they need which may also be waiting on by another control.
I diverge ... sorry.
Rob

As for Silverlight being dead and them not putting priority on it. Even if that was the case, the controls and development are almost the same for WPF, and the windows 8 RT Metro or whatever you call it now. Siliverlight is to be supported until 2021 or 2022 at least. For me it's easier to install Silverlight than WPF business applications that can't be HTML. Maybe I should make them all WPF since I always use Out of Browser mode, but I think the install/updates are just easier with Silverlight (I could be wrong).

Anyway, maybe Microsoft will see the light ... who knows, maybe it'll come back as GoldRays v1.0 ;)
HTML5 is a step backwards in terms of what it can do compared to SL5 ... but HTML5 lives in the "sandbox" and that's all Microsoft seem to care about. I guess the dream of having "grown-up" enterprise applications running on any OS and not in a browser is still just that ... a dream :(. It does boggle my mind that in this day and age we still can't do this because of fear. It's probably what 99.9% of enterprise developers want, yet we're stuck with kiddy sandbox applications and HTML5.
Rob.


<
UserControl
x:Class
=
"MyProject.View.SilverlightControl1"
xmlns:telerik
=
"http://schemas.telerik.com/2008/xaml/presentation"
mc:Ignorable
=
"d"
d:DesignHeight
=
"400"
d:DesignWidth
=
"600"
>
<
Grid
x:Name
=
"LayoutRoot"
Background
=
"White"
>
<
telerik:RadGridView ItemsSource="{Binding MyItems}"
>
<
i:Interaction.Triggers
>
<
i:EventTrigger
EventName
=
"RowActivated"
>
<
i:InvokeCommandAction
Command
=
"{Binding OpenItemCommand}"
/>
</
i:EventTrigger
>
</
i:Interaction.Triggers
>
</
telerik:RadGridView
>
</
Grid
>
</
UserControl
>
namespace MyProject.ViewModel
{
public
class
MyItems : ObservableCollection<MyItem>
{
// .....
}
public
class
MyItem : ViewModelBase
{
// .....
public
RelayCommand OpenItemCommand
{
get
{
return
new
RelayCommand(OpenItemCommandExecute);
}
}
public
void
OpenItemCommandExecute()
{
// to do anything
}
}
....

How to Display selected row from radgridview to RadTextBox in vb.net 2010?
Pls help...?
See attached Screenshot...!