Change ContextMenu color after right click

2 posts, 0 answers
  1. miki
    miki avatar
    37 posts
    Member since:
    Dec 2014

    Posted 08 Jan 2015 Link to this post

    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
  2. Stefan
    Stefan avatar
    2906 posts

    Posted 12 Jan 2015 Link to this post

    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.


    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.

Back to Top