CellMouseEnter- & CellMouseLeave-Events?

2 posts, 1 answers
  1. Froggie
    Froggie avatar
    29 posts
    Member since:
    Jan 2012

    Posted 08 Feb 2012 Link to this post

    Are there any of those Events?
    I need to change the value of a cell (Databound to BindingList with INotifyPropertyChanged) if the mouse enters a cell and reset the value if the mouse leaves the cell.
    How is this possible?
  2. Answer
    Stefan
    Admin
    Stefan avatar
    2908 posts

    Posted 13 Feb 2012 Link to this post

    Hi Sebastian,

    Thank you for writing.

    You can achieve the desired functionality by subscribing to the CellMouseMove event of RadGridView, where you can change the hovered cell appearance and reset the previously hovered cell appearance. Here is a sample:
    GridCellElement lastHoveredCell = null;
     
    void radGridView1_CellMouseMove(object sender, MouseEventArgs e)
    {
        GridCellElement cell = radGridView1.ElementTree.GetElementAtPoint(e.Location) as GridCellElement;
        if (cell != null)
        {
            if (lastHoveredCell != null)
            {
                lastHoveredCell.ResetValue(LightVisualElement.BackColorProperty, Telerik.WinControls.ValueResetFlags.Local);
                lastHoveredCell.ResetValue(LightVisualElement.DrawFillProperty, Telerik.WinControls.ValueResetFlags.Local);
                lastHoveredCell.ResetValue(LightVisualElement.GradientStyleProperty, Telerik.WinControls.ValueResetFlags.Local);
            }
            cell.DrawFill = true;
            cell.BackColor = Color.Red;
            cell.GradientStyle = Telerik.WinControls.GradientStyles.Solid;
            lastHoveredCell = cell;
        }
    }

    I hope that you find this information helpful. Should you have any other questions, do not hesitate to contact us.
     
    Kind regards,
    Stefan
    the Telerik team
    Sharpen your .NET Ninja skills! Attend Q1 webinar week and get a chance to win a license! Book your seat now >>
Back to Top