Icons in Application Menus

  • Thread starter Thread starter Siv
  • Start date Start date
S

Siv

Hi,
I have just searched MSDN and Google and can't find a tutorial about how to
add icons to menus in a VB.NET or C#.NET Windows Forms application.
Does anyone know how it's done or can point me at a tutorial that is easy to
follow.

In anticipation, thanks.

Graham Sivill
Martley, Near Worcetser UK.
 
Siv said:
Hi,
I have just searched MSDN and Google and can't find a tutorial about how
to add icons to menus in a VB.NET or C#.NET Windows Forms application.
Does anyone know how it's done or can point me at a tutorial that is easy
to follow.

In anticipation, thanks.

Graham Sivill
Martley, Near Worcetser UK.

You have to set the OwnerDraw property on the menu item. Then override the
onPaint method I believe. here is a link that shows an example of this.
Their menus are not that pretty but it should give you an idea of how to do
this. The sample is in C#, Sorry that is the first I found. Should be an
easy conversion though.
http://www.c-sharpcorner.com/Code/2002/April/OwnerDrawMenusSK.asp
 
James,
Thanks, all I could find was an old VB6 example that looked a bit Windows
API for me!

Graham Sivill
Martley, Near Worcester, UK
 
Siv said:
I have just searched MSDN and Google and can't find a tutorial about how
to add icons to menus in a VB.NET or C#.NET Windows Forms application.
Does anyone know how it's done or can point me at a tutorial that is easy
to follow.

Which version of the .NET Framework are you using? If you are using .NET
Framework 2.0 (VS 2005), simply use the built-in MenuStrip control.
 
Herfried,
I am using VB.NET 2005 with the 2.0 Framework, could you explain how the
menustrip works, I thought they were for creating pop-up menus?
Siv
 
Siv said:
I am using VB.NET 2005 with the 2.0 Framework, could you explain how the
menustrip works, I thought they were for creating pop-up menus?

Simply place a menustrip control on the form :-). You can use the new menu
control for popup menus too.
 
Herfried,

Once I figured out how to get it to dock to the top of the form I got it
working. I tried using some of the bitmaps from the "Command" section of
the VS2005 Image Library. At the moment they appear in the menu with a
magenta background, I haven't run the app yet as I have some code that needs
tidying up before running. I assume the magenta bit will appear
transparent? If not how do I get the icons to appear as normal?

As always, thanks for your help!

Siv
 
Siv said:
I tried using some of the bitmaps from the "Command" section of the
VS2005 Image Library. At the moment they appear in the menu with a magenta
background, I haven't run the app yet as I have some code that needs
tidying up before running. I assume the magenta bit will appear
transparent? If not how do I get the icons to appear as normal?

Set the menu items' 'ImageTransparentColor' property to magenta.
 
Back
Top