Create an Owner-Drawn Menu
Problem
You want to create a menu that includes pictures, formatted text, or colored item backgrounds.
Solution
Set the OwnerDraw property to True for each MenuItem control you want to draw, and handle the MeasureItem and DrawItem events.
Discussion
The MenuItem class that is included with the .NET Framework is fairly limited. It doesn’t provide any ability to change menu font, colors, or even add the common thumbnail icon. To add any of these enhancements, you’ll need to combine your menu with custom drawing logic.
Fortunately, .NET makes it easy to replace the standard drawing logic with your own custom code. All you need to do is set the OwnerDraw property for a MenuItem to True. A context menu or main menu can contain ...
Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.