)
We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to change the CustomTextFont property of the WinForms Popup menu items which gets shown when right click on toolbar area?

Platform: WinForms |
Control: PopupMenu |
Published Date: February 7, 2020 |
Last Revised Date: February 7, 2020

CustomTextFont

The text font in the context menu can be changed by getting the CommandBar using GetCommandBarManager method and get hold of DockBarContextMenu. Now the ParentBarItem's BeforePopup event has to handled to change the text font of Popup menu items. Please refer the below code snippet which illustrates this:

C#

this.mainFrameBarManager1.GetCommandBarManager().DockBarContextMenu.ParentBarItem.BeforePopup+=new CancelEventHandler(ParentBarItem_BeforePopup);
private void ParentBarItem_BeforePopup(object sender, CancelEventArgs e)
{
   foreach(BarItem baritem in this.mainFrameBarManager1.GetCommandBarManager().DockBarContextMenu.ParentBarItem.Items)
   {
      baritem.CustomTextFont=new Font("Times New Roman",8.25F);
   }
}

VB

AddHandler mainFrameBarManager1.GetCommandBarManager().DockBarContextMenu.ParentBarItem.BeforePopup, AddressOf ParentBarItem_BeforePopup
Private Sub ParentBarItem_BeforePopup(ByVal sender As Object, ByVal e As CancelEventArgs)
    For Each baritem As BarItem In Me.mainFrameBarManager1.GetCommandBarManager().DockBarContextMenu.ParentBarItem.Items
        baritem.CustomTextFont = New Font("Times New Roman",8.25F)
    Next baritem
End Sub

2X faster development

The ultimate WinForms UI toolkit to boost your development speed.
ADD COMMENT
You must log in to leave a comment

Please sign in to access our KB

This page will automatically be redirected to the sign-in page in 10 seconds.

Up arrow icon

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon