gridview cell mousehover/hand cursor

7 posts, 0 answers
  1. deva subramanian
    deva subramanian avatar
    16 posts
    Member since:
    Jun 2012

    Posted 11 Jun 2010 Link to this post

    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.
  2. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 17 Jun 2010 Link to this post

    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.
  3. deva subramanian
    deva subramanian avatar
    16 posts
    Member since:
    Jun 2012

    Posted 18 Jun 2010 Link to this post

    Hi Jack, 

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


    Thanks,
    Dev
  4. GTL Dev
    GTL Dev avatar
    14 posts
    Member since:
    May 2011

    Posted 27 Sep 2012 Link to this post

    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?
  5. Jack
    Admin
    Jack avatar
    2333 posts

    Posted 01 Oct 2012 Link to this post

    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 >>
  6. Chris
    Chris avatar
    121 posts
    Member since:
    Oct 2015

    Posted 04 Jul 2018 in reply to Jack Link to this post

    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

  7. Dess | Tech Support Engineer, Sr.
    Admin
    Dess | Tech Support Engineer, Sr.  avatar
    4132 posts

    Posted 04 Jul 2018 Link to this post

    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.
Back to Top