RadGridView - click event

6 posts, 0 answers
  1. Terje Johansen
    Terje Johansen avatar
    28 posts
    Member since:
    Mar 2010

    Posted 12 Aug 2011 Link to this post

    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)
  2. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 12 Aug 2011 Link to this post

    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 >>

  3. UI for WPF is Visual Studio 2017 Ready
  4. Terje Johansen
    Terje Johansen avatar
    28 posts
    Member since:
    Mar 2010

    Posted 12 Aug 2011 Link to this post

    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.
  5. Vanya Pavlova
    Admin
    Vanya Pavlova avatar
    2019 posts

    Posted 12 Aug 2011 Link to this post

    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 >>

  6. Terje Johansen
    Terje Johansen avatar
    28 posts
    Member since:
    Mar 2010

    Posted 12 Aug 2011 Link to this post

    Thanks! I think I got what I need.
  7. Antonio Jesús
    Antonio Jesús avatar
    2 posts
    Member since:
    Jun 2011

    Posted 21 Mar 2012 Link to this post

    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.
Back to Top
UI for WPF is Visual Studio 2017 Ready