Home All Groups Group Topic Archive Search About

Icons in Application Menus

Author
15 Mar 2006 5:49 PM
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.

Author
15 Mar 2006 6:05 PM
James Jardine
"Siv" <dotnet@remove_me.sivill.com> wrote in message
news:OBvrBjFSGHA.4440@TK2MSFTNGP11.phx.gbl...
> 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
Author
15 Mar 2006 6:18 PM
Siv
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

Show quoteHide quote
"James Jardine" <james.jard***@geoage.com> wrote in message
news:uXsNXsFSGHA.4752@TK2MSFTNGP10.phx.gbl...
>
> "Siv" <dotnet@remove_me.sivill.com> wrote in message
> news:OBvrBjFSGHA.4440@TK2MSFTNGP11.phx.gbl...
>> 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
>
Author
15 Mar 2006 6:48 PM
James Jardine
Show quote Hide quote
"Siv" <dotnet@remove_me.sivill.com> wrote in message
news:%23qjEhzFSGHA.4456@TK2MSFTNGP14.phx.gbl...
> 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
>
> "James Jardine" <james.jard***@geoage.com> wrote in message
> news:uXsNXsFSGHA.4752@TK2MSFTNGP10.phx.gbl...
>>
>> "Siv" <dotnet@remove_me.sivill.com> wrote in message
>> news:OBvrBjFSGHA.4440@TK2MSFTNGP11.phx.gbl...
>>> 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
>>
>
>

Here is another link http://www.codeproject.com/cs/menu/menuimage.asp   that
has better looking menus..   I hope this helps get you started.  Good Luck

jjardine
Author
15 Mar 2006 10:17 PM
Herfried K. Wagner [MVP]
"Siv" <dotnet@remove_me.sivill.com> schrieb:
> 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.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
15 Mar 2006 11:06 PM
Siv
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

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:ODsSL5HSGHA.2536@tk2msftngp13.phx.gbl...
> "Siv" <dotnet@remove_me.sivill.com> schrieb:
>> 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.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
Author
15 Mar 2006 11:17 PM
Herfried K. Wagner [MVP]
"Siv" <dotnet@remove_me.sivill.com> schrieb:
> 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.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
15 Mar 2006 11:50 PM
Siv
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

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:OV6wwaISGHA.4944@TK2MSFTNGP10.phx.gbl...
> "Siv" <dotnet@remove_me.sivill.com> schrieb:
>> 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.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>
Author
16 Mar 2006 12:04 AM
Herfried K. Wagner [MVP]
"Siv" <dotnet@remove_me.sivill.com> schrieb:
> 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.

--
M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://classicvb.org/petition/>
Author
16 Mar 2006 12:17 AM
Siv
Herfried,
Thanks, this fixes the problem.
Siv

Show quoteHide quote
"Herfried K. Wagner [MVP]" <hirf-spam-me-here@gmx.at> wrote in message
news:eUWYF1ISGHA.5036@TK2MSFTNGP12.phx.gbl...
> "Siv" <dotnet@remove_me.sivill.com> schrieb:
>> 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.
>
> --
> M S   Herfried K. Wagner
> M V P  <URL:http://dotnet.mvps.org/>
> V B   <URL:http://classicvb.org/petition/>