Change MenuStrip colors

Ask questions about creating Graphical User Interfaces (GUI) in PowerShell and using WinForms controls.
Forum rules
Do not post any licensing information in this forum.

Any code longer than three lines should be added as code using the 'Select Code' dropdown menu or attached as a file.
This topic is 10 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked
User avatar
rzarka
Posts: 1
Last visit: Sat Feb 25, 2017 5:38 am

Change MenuStrip colors

Post by rzarka »

How do I change the default colors for MenuStrip control? I can easily change the primary ForeColor and BackColor, but can't figure out how to change the hover and click colors.

Image
User avatar
davidc
Posts: 5913
Last visit: Mon Jul 08, 2019 8:55 am
Been upvoted: 2 times

Re: Change MenuStrip colors

Post by davidc »

Menustrip doesn't have built in for color changes when you hover or click, but you probably can use the MouseEnter and MouseLeave events of the menu items to create the effect.

In the event block you can change the menu item's font and colors.
PowerShell Code
Double-click the code block to select all.
$ToolStripMenuItem_MouseEnter={
	$this.Font = New-Object System.Drawing.Font -Args ($menustrip1.Font.FontFamily, $menustrip1.Font.Size, [System.Drawing.FontStyle]::Bold)
	$this.ForeColor = 'Red'
}

$ToolStripMenuItem_MouseLeave={

	$this.Font = $menustrip1.Font
	$this.ForeColor = $menustrip1.ForeColor
}
David
David
SAPIEN Technologies, Inc.
This topic is 10 years and 11 months old and has exceeded the time allowed for comments. Please begin a new topic or use the search feature to find a similar but newer topic.
Locked