Re: how to change the color of the bar of MainMenu?
From: phoenix (patient0_at_skynetWORK.be)
Date: 05/28/04
- Next message: Willie Neil: "Calling methods of a user control"
- Previous message: Willie Neil: "Advice on adding user control to panel."
- In reply to: Rhy Mednick: "Re: how to change the color of the bar of MainMenu?"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 28 May 2004 23:58:15 +0200
He asked for the bar of the mainmenu, that's the top level one and not the
menuitems. You can indeed draw the menuitems with a different background but
then you'll see that the rest of the bar (e.g. the part to the right of
'Help' in most cases) which doesn't contain items is still painted in the
same old color. AFAIK there really is no way to color that last part unless
you create a whole new mainmenu.
Yves
"Rhy Mednick" <rhy@rhy.com> schreef in bericht
news:e2MiTabREHA.3420@TK2MSFTNGP11.phx.gbl...
There's not a built-in way to change the background color, but if you create
an owner-drawn menu then you can draw a new background yourself. The
downside to this is that you have to manually draw the text for each of the
menu items yourself.
In addition to drawing the menu items yourself, you'll want to add the
following code to the DrawItem event of your menu item.
private void menuItem1_DrawItem(object sender,
System.Windows.Forms.DrawItemEventArgs e)
{
e.Graphics.FillRectangle (new
SolidBrush(Color.Yellow),e.Bounds.Left,e.Bounds.Top,this.ClientRectangle.Wid
th,e.Bounds.Height);
}
That'll change the background of the menu to yellow, but you could easily
replace that with any color. As an attractive alternative, you could
replace the SolidBrush object with a LinearGradientBrush and draw a
background that looks more like the Office menus. Below I've included a few
links to some resources for creating owner-drawn menus.
MSDN Magazine article on owner-drawn menus:
http://msdn.microsoft.com/msdnmag/issues/04/02/CuttingEdge/
Simple code example:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsmenuitemclassdrawitemtopic.asp
"Altex" <Altex@yahoo.com> wrote in message
news:uytyN8oMEHA.1272@tk2msftngp13.phx.gbl...
> Hi, how can I change the color of the bar of MainMenu?
> thanks
>
>
- Next message: Willie Neil: "Calling methods of a user control"
- Previous message: Willie Neil: "Advice on adding user control to panel."
- In reply to: Rhy Mednick: "Re: how to change the color of the bar of MainMenu?"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|