Determine the Highlighted Row

2 posts, 0 answers
  1. WILLIAM
    WILLIAM avatar
    134 posts
    Member since:
    Jun 2012

    Posted 05 Jan 2012 Link to this post

    I have implemented a grid in our application, and as you click on various rows, that row becomes highlighted in an orangish color. While at the same, as you hover over other rows, they are highlighted in a lighter yellowish color. When I do a right-mouse click, the SelectedItem and the CurrentItem in the radGridView is the last record that the user actually clicked on. I want to be able to determine the highlighted row, and set it as the selected item.

    The scenario that I'm trying to solve is to basically eliminate an additional click. If I've selected record #3 in a grid of 10 rows for some reason, but then I hover over record #6 and do a right-click to perform an action on that row, I need to be able to determine that row and set it as the selected item. Otherwise I have to actually click record #6 and then do a right-mouse click.

    I've seen other requests for a property to return the highlighted row(s). Is there a way to accomplish this now, and are you planning on implemented this feature soon?
  2. Maya
    Admin
    Maya avatar
    4062 posts

    Posted 06 Jan 2012 Link to this post

    Hello William,

    You can handle MouseRightButtonDown event for example and set the clicked item as the selected one for the grid. For example:

    public MainPage()
            {
                InitializeComponent();
                 
                this.clubsGrid.MouseRightButtonDown += new MouseButtonEventHandler(clubsGrid_MouseRightButtonDown);
            }
     
            void clubsGrid_MouseRightButtonDown(object sender, MouseButtonEventArgs e)
            {
                var clickedElement = e.OriginalSource as FrameworkElement;
                var clickedItem = clickedElement.DataContext;
                this.clubsGrid.SelectedItem = clickedItem;
            }
     

    All the best,
    Maya
    the Telerik team

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

Back to Top