is there any mouse click event in rad gridview?
In my last wpf project i want to click on radgridview that time the selected row details display on respective controls?
how to get clicked row data in gridview?
can u suggest some sample code here?
7 Answers, 1 is accepted
RadGridView does provide a bunch of Mouse-click events (MouseDoubleClick, MouseLeftButtonDown, PreviewMouseRightButtonUp, etc.). However, I am not quite sure what are your exact requirements and consequently, I am not able to provide you with an appropriate solution. Do you want to visualize the RowDetails once the row is selected (that can be achieved by setting the RowDetailsVisibilityMode property of the grid to VisibleWhenSelected) ? Or you want to get the item on selecting it (you may use the SelectionChanged event) ?
Maya
the Telerik team

if i use mouse double click event.it fire when user click on the header of the gridview.
Generally, when you double click on a row, RowActivated event will be fired. However, it will be fired for the GridViewHeaderRow as well. What you could do is to verify the type of the row and execute your logic only for the type you want. For example:
private void clubsGrid_RowActivated(object sender, RowEventArgs e)
{
if(e.Row is GridViewHeaderRow)
{
MessageBox.Show("You clicked on a header row");
}
else if(e.Row is GridViewRow)
{
MessageBox.Show("You clicked on a row");
}
}
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

I find this example to be inaccurate since that event isn't fired when the user double clicks the header row.
I would like to see an example for handling double click on a row that works and show how to access the cell clicked on.
If you want to get the cell you double-clicked on, you can work direly with MouseDoubleClick event. For example:
private void clubsGrid_MouseDoubleClick(object sender, System.Windows.Input.MouseButtonEventArgs e)
{
var clickedElement = e.OriginalSource as FrameworkElement;
if(clickedElement != null)
{
if(clickedElement.ParentOfType<
GridViewCell
>() != null)
{
MessageBox.Show("You clicked on a cell");
}
if (clickedElement.ParentOfType<
GridViewHeaderCell
>() != null)
{
MessageBox.Show("You clicked on a header cell");
}
}
}
Since double click on a cell places it in edit-mode, you will get the cell either if the grid is read-only or it is already in edit-mode.
Does this approach correspond to your requirements ?
All the best,
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

I had seen this code before and it doesn't work for me (and some other according to the forums).
I get a compile error saying that ParentOfType is not a part of FrameworkElement. This could be caused by incorrect "using" but I used JustCode to add the missing "using".
Beside that this code does not demonstrate how to access the value of the clicked cell or specific cell in the clicked row.
My workaround for this task was to use the GridRowActivated event and then get the underlying data with (e.Row.DataContext as DataRow).ItemArray[0] .
This works for me since I will always be acting up on the first column but not clicked cell.
I have been using Telerik RadControls for Windows and ASP.NET (and .. ...) where documentation is very verbose and detailed. That gives the impression that the documentation for the WPF controls is minimal. The maturity of the other platforms explains the difference, you at Telerik have spoiled us with good support so we expect nothing short of perfect, keep up the good work.
You need to add reference to Telerik.Windows.Controls assembly in the class you use ParentOfType<T>() and ChildrenOfType<T> extension methods. As for getting the value of the cell, you can just cast the element you found through ParentOfType<GridViewCell>() method and get its Value property.
Considering our documentation, we really make a lot of efforts for improving it and including all the information that might be helpful for our customers. And I am really happy to see that our support delivers what you expect and hopefully even more.
Maya
the Telerik team
Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>