context menu highlight color

Hello,

I'm attempting to change the color of the mouseover hover color for menu items within the context menu of the the TabbedGroupMDIManager. I have referenced the link below on appearance settings, but nothing is listed there. I was hoping someone could assist. Also, I'm using the Office2019Colorful theme if that matters.


https://help.syncfusion.com/windowsforms/tabbedmdi/appearance-settings

I originally thought that changing the "ContextMenuItem.MetroColor" property would do the trick, but it does not.

I've also looked into properties of BarItems within the TabbedGroupedMDIManager BeforeDropDownPopup event, but nothing seem relevant here either.

Looking for some assistance.

Thanks.


6 Replies 1 reply marked as answer

TB Thirupathi Bala Krishnan Syncfusion Team September 27, 2021 03:51 PM UTC

Hi Brent, 

We have analyzed your reported query “How to change the color of the mouseover hover color for menu items within the context menu of the the TabbedGroupMDIManager”. We do not currently support changing the hover color value. Meanwhile, we attempted a workaround solution to meet the reported requirement. So we'll provide the further details on 28 Sep 2021. 

We appreciate your patience until then. 

Regards,
Thirupathi B. 



TB Thirupathi Bala Krishnan Syncfusion Team September 29, 2021 09:24 AM UTC

Hi Brent, 
 
Thanks for your patience. 
 
We have checked your reported query “How to change the color of the mouseover hover color for menu items within the context menu of the the TabbedGroupMDIManager”. You can achieve this requirement by doing the following code changes in your application.  
  • Obtain the instance of the ContextMenu from the TabbedGroupMDIManager.
  • Set the HoverBackColor value to the object using Reflection.
  • You can set the HoverBackColor value directly in the BarItemStyleInfo class for Docking manager.
 
Please refer the following code sample. 
 
# Form1.cs 
 
        private void tabbedMDIManager_TabControlAdded(object sender, TabbedMDITabControlEventArgs args) 
        { 
            PropertyInfo propertyInfo = this.tabbedGroupedMDIManager1.GetType().BaseType.GetProperty("ContextMenu", BindingFlags.NonPublic | BindingFlags.Instance); 
            if (propertyInfo != null) 
            { 
                object obj = propertyInfo.GetValue(this.tabbedGroupedMDIManager1); 
                (obj as PopupMenu).ThemeStyle.BarItemStyle.HoverBackColor = Color.Yellow; 
                propertyInfo.SetValue(this.tabbedGroupedMDIManager1, obj, null); 
            } 
        } 
        private void DockingManager1_DockContextMenu(object sender, DockContextMenuEventArgs arg) 
        { 
            arg.ContextMenu.ThemeStyle.BarItemStyle.HoverBackColor = Color.Aqua; 
        } 
 
 
 
Please let us know if you need any further assistance. 
 
Regards,
Thirupathi B.
 


Marked as answer

ST Stoked September 29, 2021 04:41 PM UTC

Hello.

While the example was helpful, I now have another similar issue regarding context menu's with the TabbedGroupedMDIManager. I've included a screen capture below.

While the code previously provided changes the background color for the context menu when right-clicking on the tab, how can the background color be changed for the DropDownButton shown?


I cannot seem to find a property to modify for this ability (or perhaps overlooked it). Please guide me in the right direction to accomplish this latest ask.

Thank you.



TB Thirupathi Bala Krishnan Syncfusion Team September 30, 2021 07:26 AM UTC

Hi Brent,  
  
Thanks for the update.  
  
We have checked your reported query “How to change the color of the mouseover hover color for menu items within the context menu(dropdown button) of the the MDITabPanel”. You can achieve this requirement by doing the following code changes in your application.   
  • Hook the BeforeDropDownPopup event hanlder and then find the MDITabPanel instance.
  • Obtain the instance of the m_pmDropDownPopup from the MDITabPanel.
  • Set the HoverBackColor value to the object using Reflection.
Please refer the following code sample.  
  
# Form1.cs  
 
        public Form1() 
        { 
            InitializeComponent(); 
            SkinManager.LoadAssembly(typeof(Office2019Theme).Assembly); 
            dockingManager1.ThemeName = "Office2019Colorful"; 
            tabbedGroupedMDIManager1.ThemeName = "Office2019Colorful"; 
            tabbedGroupedMDIManager1.CloseButtonVisible = true; 
            tabbedGroupedMDIManager1.DropDownButtonVisible = true; 
            AddItems(); 
 
            tabbedGroupedMDIManager1.BeforeDropDownPopup += TabbedGroupedMDIManager1_BeforeDropDownPopup; 
        } 
  
        private void TabbedGroupedMDIManager1_BeforeDropDownPopup(object sender, DropDownPopupEventArgs e) 
        { 
            MDITabPanel panel = tabbedGroupedMDIManager1.TabGroupHosts[0].MDITabPanel; 
 
            FieldInfo fieldInfo = panel.GetType().GetField("m_pmDropDownPopup", BindingFlags.NonPublic | BindingFlags.Instance); 
            if (fieldInfo != null) 
            { 
                object obj = fieldInfo.GetValue(panel); 
                (obj as PopupMenu).ThemeStyle.BarItemStyle.HoverBackColor = Color.Yellow; 
                fieldInfo.SetValue(panel, obj); 
            } 
        }  
  
 
Please let us know if you need any further assistance.  
  
Regards,
Thirupathi B.
 
 
 



ST Stoked September 30, 2021 11:01 AM UTC

Excellent. All provided solutions work as expected. Much appreciated.



TB Thirupathi Bala Krishnan Syncfusion Team September 30, 2021 05:06 PM UTC

Hi Brent, 
 
Thanks for confirming that our solution meets your requirement.  Please let us know if you need any further assistance on this. As always, we will be happy to assist you. 
 
Regards,
Thirupathi B.
 


Loader.
Up arrow icon