Windows Develop Bookmark and Share   
 index > Windows Forms General > How can I add images to main menu in VS.NET 2003?
 

How can I add images to main menu in VS.NET 2003?

How can I add images to main menu in VS.NET 2003 while developing the WinForms application?
Sunny Chen  Friday, March 31, 2006 5:16 AM

Are you familiar with GDI?  You need to know something about GDI in order to make use of this feature.

When you set the OwnerDraw to true, whenever the menu has to be painted, it will trigger the DrawItem event.  The event passes you a a DrawItemEventArgs which contains a Graphics object and Bounds.  The Bounds is the dimensions of the area for you to draw.  You can use the methods of Graphics to write or draw anything you like and also add images.

The MSDN Library documentation for DrawItem event has an example. If it is not illuminating enough, try a search on DrawItem.  There are many examples out there.  But you would still need to know GDI.

K.Kong  Friday, March 31, 2006 6:04 AM

I think the answer may lie in making the OwnerDraw property to true and then handling the DrawItem event.

HTH

K.Kong  Friday, March 31, 2006 5:23 AM
Thank you for answering. But could you describes in more detail on how to draw the image in DrawItem event? Thank you very much!
Sunny Chen  Friday, March 31, 2006 5:25 AM

Are you familiar with GDI?  You need to know something about GDI in order to make use of this feature.

When you set the OwnerDraw to true, whenever the menu has to be painted, it will trigger the DrawItem event.  The event passes you a a DrawItemEventArgs which contains a Graphics object and Bounds.  The Bounds is the dimensions of the area for you to draw.  You can use the methods of Graphics to write or draw anything you like and also add images.

The MSDN Library documentation for DrawItem event has an example. If it is not illuminating enough, try a search on DrawItem.  There are many examples out there.  But you would still need to know GDI.

K.Kong  Friday, March 31, 2006 6:04 AM

You can use google to search for other answers

Custom Search

More Threads

• Mouse Click Question
• Getting the word when a mouse hovers and displaying tooltip only if its a link
• How do you supply basic authentication or userid/password to WebBrowser class or Document property programaticlly
• making controls resizable for user
• C# - Compare Date Column from DataGrid to Today's Date
• button appearance
• How to change default language of a TextBox?
• MDI Child Layout Issues
• Wait for event before continuing in method
• How To Get AssemblyName of the application