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

gridview cell mousehover/hand cursor

6 Answers 318 Views
GridView
This is a migrated thread and some comments may be shown as answers.
deva subramanian
Top achievements
Rank 1
deva subramanian asked on 11 Jun 2010, 02:11 PM
Hi all,

am having a Radgridview with four columns, one of the column  i made as a linklabel, when i do a mouse over i should get the hand cursor, only for that particular  column.... please assist   waiting for your reply......

Thanks in Advance,
Dev.

6 Answers, 1 is accepted

Sort by
0
Jack
Telerik team
answered on 17 Jun 2010, 09:30 AM
Hi deva subramanian,

This can be achieved by handling the MouseMove event of RadGridView and by using the ElementTree.GetElementAtPoint method. Consider the code snippet below:

Cursor originalCursor;
 
void radGridView1_MouseMove(object sender, MouseEventArgs e)
{
    GridDataCellElement cell = this.radGridView1.RootElement.ElementTree.GetElementAtPoint(e.Location) as GridDataCellElement;
    if (cell != null && ((GridViewDataColumn)cell.ColumnInfo).UniqueName == "Value")
    {
        if (originalCursor == null)
        {
            originalCursor = this.radGridView1.Cursor;
            this.radGridView1.Cursor = Cursors.Hand;
        }
         
    }
    else
    {
        if (originalCursor != null)
        {
            this.radGridView1.Cursor = originalCursor;
            originalCursor = null;
        }
    }
}

I hope this helps.

 

Sincerely yours,
Jack
the Telerik team

Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
0
deva subramanian
Top achievements
Rank 1
answered on 18 Jun 2010, 07:53 AM
Hi Jack, 

    Thank you very much for your reply ... its working fine ...take care 


Thanks,
Dev
0
GTL Dev
Top achievements
Rank 2
answered on 27 Sep 2012, 06:29 PM
This doesn't work if its a command column and it has a button with an image. if you move the mouse around the outer edges of the column it will work briefly but if your pointer touches the button image at all it reverts back to the default cursor.

Any recommendations?
0
Jack
Telerik team
answered on 01 Oct 2012, 01:18 PM
Hi,

You can solve this issue by using a slightly modified version of this sample. Here is the code:
void radGridView1_MouseMove(object sender, MouseEventArgs e)
{
    RadElement element = this.radGridView1.RootElement.ElementTree.GetElementAtPoint(e.Location);
    GridDataCellElement cell = element as GridDataCellElement;
    if (cell == null && element != null)
    {
        cell = element.FindAncestor<GridDataCellElement>();
    }
    if (cell != null && cell.ColumnInfo.Name == "xx")
    {
        if (originalCursor == null)
        {
            originalCursor = this.radGridView1.Cursor;
            this.radGridView1.Cursor = Cursors.Hand;
        }
 
    }
    else
    {
        if (originalCursor != null)
        {
            this.radGridView1.Cursor = originalCursor;
            originalCursor = null;
        }
    }
}

The FindAncestor method is used to locate the cell which owns the button element.

I hope this helps.

Regards,
Jack
the Telerik team
RadControls for WinForms Q2'12 release is now live! Check out what's new or download a free trial >>
0
Chris
Top achievements
Rank 1
Veteran
Iron
answered on 04 Jul 2018, 06:55 AM

HI

 

CellMouseMove not invoked after move from cell to Grid's space area and Cursor would not be restored.

Please test more and more.

 

Best Regards

 

Chris

0
Dess | Tech Support Engineer, Principal
Telerik team
answered on 04 Jul 2018, 10:14 AM
Hello, Chris,    

The RadGridView.CellMouseMove event is expected to be fired when you move the mouse over the cells. If you don't move the cursor over a cell, the event is not expected to be fired. In this case, the RadGridView.MouseMove event is fired. As to the RadGridView.Cursor, it is set to Default when you hover a cell. If you are between the cells in the thin border that separates the column, the cursor is changed in order to allow resizing the columns. If you need to have the same cursor in the grid, you can handle the CursorChanged event and set the RadGridView.Cursor property to Default if it is changed to some other type.  
private void radGridView1_CursorChanged(object sender, EventArgs e)
{
    if (this.radGridView1.Cursor!=Cursors.Default)
    {
        this.radGridView1.Cursor = Cursors.Default;
    }
}

I hope this information helps. If you have any additional questions, please let me know. 
 
Regards,
Dess
Progress Telerik
Try our brand new, jQuery-free Angular components built from ground-up which deliver the business app essential building blocks - a grid component, data visualization (charts) and form elements.
Tags
GridView
Asked by
deva subramanian
Top achievements
Rank 1
Answers by
Jack
Telerik team
deva subramanian
Top achievements
Rank 1
GTL Dev
Top achievements
Rank 2
Chris
Top achievements
Rank 1
Veteran
Iron
Dess | Tech Support Engineer, Principal
Telerik team
Share this question
or