Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change ContextMenu Font Size in C#

Is it possible to change the font size used in a ContextMenu using the .NET Framework 3.5 and C# for a desktop application? It seems it's a system-wide setting, but I would like to change it only within my application.

like image 373
Ray Li Avatar asked Mar 02 '23 07:03

Ray Li


2 Answers

If you are defining your own context menu via a ContextMenuStrip in Windows Forms, use the Font property.

If you are defining your own context menu via a ContextMenu in WPF, use the various Fontxxx properties such as FontFamily and FontSize.

You cannot change the default context menus that come with controls; those are determined by system settings. So if you want the "Copy/Cut/Paste/etc." menu with a custom font size for a WinForms TextBox, you'll have to create a ContextMenuStrip with the appropriate font size and assign it to the TextBox's ContextMenuStrip property.

like image 84
OwenP Avatar answered Mar 05 '23 17:03

OwenP


In WPF:

<Window.ContextMenu FontSize="36">
    <!-- ... -->
</Window.ContextMenu

In WinForms:

contextMenuStrip1.Font = new System.Drawing.Font("Segoe UI", 24F);
like image 45
Ben Straub Avatar answered Mar 05 '23 16:03

Ben Straub