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

CellMouseEnter- & CellMouseLeave-Events?

1 Answer 153 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Froggie
Top achievements
Rank 1
Froggie asked on 08 Feb 2012, 11:32 AM
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?

1 Answer, 1 is accepted

Sort by
0
Accepted
Stefan
Telerik team
answered on 13 Feb 2012, 10:09 AM
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 >>
Tags
GridView
Asked by
Froggie
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or