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.
Locked
User avatar
rzarka
Posts: 1
Joined: Sun Mar 03, 2013 12:44 pm

Change MenuStrip colors

Post by rzarka » Sat Apr 06, 2013 11:00 am

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: 5818
Joined: Thu Aug 18, 2011 4:56 am

Re: Change MenuStrip colors

Post by davidc » Mon Apr 08, 2013 9:27 am

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.

Locked