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

RadGridView - click event

5 Answers 726 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Terje Johansen
Top achievements
Rank 1
Terje Johansen asked on 12 Aug 2011, 11:55 AM
The radgridview has an event for MouseDoubleClick, but is there a way you can catch a single click?
I need to hook on to the "click event" when the selected row in the grid is clicked(once)

5 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 12 Aug 2011, 12:08 PM
Hello Terje Johansen,

 


You may subscribe to the SelectionChanging/SelectionChanged event of RadGridView to achieve the desired result. Please refer to our online documentation for further info. 


If you need any further assistance do not hesitate to contact us!


Regards,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Terje Johansen
Top achievements
Rank 1
answered on 12 Aug 2011, 12:22 PM
Hi, thanks for quick replay.

Seems like the SelectionChanging/SelectionChanged event is triggered when you fill the grid with data or when you edit on one of the rows.

If I click on the selected row (after the grid is populated and one row already is selected) none of these events are triggered.
0
Vanya Pavlova
Telerik team
answered on 12 Aug 2011, 12:38 PM
Hello Terje Johansen,

 


When the SelectionUnit is set to FullRow, the e SelectionChanged event is fired first and after that the CurrentCellChanged event fires as it was described in our docs.
You may also write some custom code for such purpose (without going in edit mode) - through subscribing to the RadGridView's RowLoaded event and attach to the MouseLeftButtonDown of a GridViewRow:



private void RadGridView_RowLoaded(object sender, Telerik.Windows.Controls.GridView.RowLoadedEventArgs e)
      {
          var row = e.Row as GridViewRow;
          if (row != null)
          {
              this.AddHandler(GridViewRow.MouseLeftButtonDownEvent,
           new MouseButtonEventHandler(GridViewRow_MouseLeftButtonDown), true);
          }
      }
 
      private void GridViewRow_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
      {
          MessageBox.Show("Hi");
      }

 

Kind regards,
Vanya Pavlova
the Telerik team

Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

0
Terje Johansen
Top achievements
Rank 1
answered on 12 Aug 2011, 01:10 PM
Thanks! I think I got what I need.
0
Antonio Jesús
Top achievements
Rank 1
answered on 21 Mar 2012, 08:27 PM
Hello Vanya,

To completing your answer/workaround to get the row clicked event I would change only one small detail on the code you posted. Where you wrote 'this.AddHandler...' must be 'row.AddHandler...' because of if you have more than one RadGridView into the same control/window. If not, you will receive the clicked event for all rows of all RadGridViews you have into the control/window where the required one is located.

It's only a small detail that had made me think for a while :)

Best regards,

Antonio Jesús.
Tags
GridView
Asked by
Terje Johansen
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Terje Johansen
Top achievements
Rank 1
Antonio Jesús
Top achievements
Rank 1
Share this question
or