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

RadGridView MouseMove ChildView

3 Answers 234 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Bilgehan
Top achievements
Rank 1
Bilgehan asked on 09 Sep 2012, 01:57 PM
In hierachical gridview in mousemove event we can get a reference to ViewTemplate the mouse is over,but  how can I get the cell in ViewTemplate that the mouse is over?

Basically I want to achieve to change the Cursor to Hand in some cells of ChildView. I am not sure if this can be achieved by som other way.

Ex:

radGridView.ElementTree.GetElementAtPoint(e.Location)
this give us the ViewTemplate mouse is over, from here I want to get the cell mouse is over.


Thanks in advance

3 Answers, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 10 Sep 2012, 10:15 AM
Hi Bilgehan,

Thank you for writing.

Here is how you can get the cell element under mouse:
void radGridView1_MouseMove(object sender, MouseEventArgs e)
{
    GridCellElement cellElement = radGridView1.ElementTree.GetElementAtPoint(e.Location) as GridCellElement;
    if (cellElement != null)
    {
        //you got the cell
    }
}

Once you get it you can get its row, column, template, etc.

I hope this helps.
 
Greetings,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Bilgehan
Top achievements
Rank 1
answered on 10 Sep 2012, 11:48 AM
Hi Stefan;

Thank you for answering.

The problem is this is a Hierarchical  grid. And the mouse is over a cell in child template.

So

radGridView1.ElementTree.GetElementAtPoint(e.Location) 

gices us a reference of  Telerik.WinControls.UI.RadGridViewElement 
- radGridViewList.ElementTree.GetElementAtPoint(e.Location) {Telerik.WinControls.UI.RadGridViewElement} Telerik.WinControls.RadElement {Telerik.WinControls.UI.RadGridViewElement}

if we try to cast it to   GridCellElement as you suggested 

GridCellElement cellElement = radGridView1.ElementTree.GetElementAtPoint(e.Location) as GridCellElement; 

cellElement is null. So we have nothing from there.

I hope I explained the situation more clearly.

Regards

0
Accepted
Stefan
Telerik team
answered on 10 Sep 2012, 01:48 PM
I am able to get the cell element with the below solution. Attached you can find a sample project demonstrating that. If you continue experiencing this issue, please provide me with code snippets of your application that will allow me to replicate this behavior on my end. Once I do that I will be able to help you with it.
 
Greetings,
Stefan
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
Tags
GridView
Asked by
Bilgehan
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Bilgehan
Top achievements
Rank 1
Share this question
or