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

Determine the Highlighted Row

1 Answer 52 Views
GridView
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
WILLIAM
Top achievements
Rank 1
WILLIAM asked on 05 Jan 2012, 09:25 PM
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?

1 Answer, 1 is accepted

Sort by
0
Maya
Telerik team
answered on 06 Jan 2012, 07:47 AM
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 >>

Tags
GridView
Asked by
WILLIAM
Top achievements
Rank 1
Answers by
Maya
Telerik team
Share this question
or