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

Change ContextMenu color after right click

1 Answer 82 Views
ContextMenu
This is a migrated thread and some comments may be shown as answers.
miki
Top achievements
Rank 1
miki asked on 08 Jan 2015, 03:27 PM
I have GridView with ContextMenu, i added to this ContextMenu several options after the user click right click on item from my GridView  and i want to know how can i change the color of the item that the mouse is in, you can see he default color in the attach screenshot

1 Answer, 1 is accepted

Sort by
0
Stefan
Telerik team
answered on 12 Jan 2015, 12:10 PM
Hello Miki,

Thank you for writing.

Here is how you can change the hovered item color of the context menu for RadGridView:
void radGridView1_ContextMenuOpening(object sender, ContextMenuOpeningEventArgs e)
{
    e.ContextMenu.MouseMove += ContextMenu_MouseMove;
}
 
RadMenuItem lastHoveredItem;
void ContextMenu_MouseMove(object sender, MouseEventArgs e)
{
    RadDropDownMenu menu = (RadDropDownMenu)sender;
    RadMenuItem hoveredItem = menu.ElementTree.GetElementAtPoint(e.Location) as RadMenuItem;
    if (hoveredItem != null)
    {
        if (lastHoveredItem != null && lastHoveredItem != hoveredItem)
        {
            lastHoveredItem.FillPrimitive.ResetValue(FillPrimitive.BackColorProperty, ValueResetFlags.Local);
        }
 
        hoveredItem.FillPrimitive.BackColor = Color.Red;
        lastHoveredItem = hoveredItem;
    }
}

I hope that you find this information useful. Should you have any other questions, do not hesitate to contact us.

Regards,
Stefan
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
ContextMenu
Asked by
miki
Top achievements
Rank 1
Answers by
Stefan
Telerik team
Share this question
or