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

Programmatically Selecting the Highlighted Item

1 Answer 57 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Mike
Top achievements
Rank 2
Mike asked on 08 Jan 2009, 08:29 PM

Hi Guys,

How do I programmatically select the highlighted item?

We have implemented buttons on our grid.  Please refer to http://www.telerik.com/community/forums/winforms/gridview/radmenuitem-in-radgridview-events.aspx for the code.

Currently the user must select the row before they can click the button.  We have added code to the mouseover the change the radgrid icon and button color.


 

 void lblLabel_MouseEnter(object sender, EventArgs e)  
        {  
            this.gvManageDocs.Cursor = Cursors.Hand;  
            ((RadLabelElement)sender).ForeColor = Color.Red;  
        } 

 

 


What I would like to do is when the user hovers over a button to auto select the row so they only have to click once to activate the button.

How do I do that?

~Mike

1 Answer, 1 is accepted

Sort by
0
Nikolay
Telerik team
answered on 10 Jan 2009, 05:25 PM

Hello Mike,

Thank you for the question.

In order to get to the desired behavior, please consider using the following code snippet:

void lblLabel_MouseEnter(object sender, EventArgs e)  
{  
    this.radGridView1.Cursor = Cursors.Hand;  
    ((RadLabelElement)sender).ForeColor = Color.Red;  
    ((GridDataRowElement)((RadLabelElement)sender).Parent.Parent.Parent.Parent).RowInfo.IsSelected = true;  
    this.radGridView1.GridElement.Update(GridUINotifyAction.StateChanged);  

By the Parent property of the RadLabelElement we get the GridViewRowElement. Then we take its RowInfo and set its IsSelected to true. Finally, we call the Update method in order to get the UI updated.

Contact me, if you need additional assistance.

All the best,

Nikolay
the Telerik team

Check out Telerik Trainer, the state of the art learning tool for Telerik products.
Tags
GridView
Asked by
Mike
Top achievements
Rank 2
Answers by
Nikolay
Telerik team
Share this question
or