Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MainMenu DrawItem, items to the right disapears when item selected

Status
Not open for further replies.

drey8

Programmer
Aug 31, 2004
17
US
I am changing the background color of my main menu, but I am having a problem with the items to the right of the seleced item disapearing. I am including the code bellow. Does any one knows how to resolve this problem?
Thank you

MenuItem s = (MenuItem)sender ;
string s1 = s.Text ;

StringFormat sf = new StringFormat();
sf.Alignment = StringAlignment.Center ;
Brush brush = new System.Drawing.SolidBrush(Color.LightSteelBlue);

Rectangle area = new Rectangle(e.Bounds.X , e.Bounds.Y, this.ClientRectangle.Right-(e.Bounds.X-this.ClientRectangle.X-4), 19);
System.Diagnostics.Debug.WriteLine(area.X.ToString(),area.Width.ToString());
e.Graphics.FillRectangle(brush,area);

Rectangle rc = new Rectangle(e.Bounds.X+1 , e.Bounds.Y+1, e.Bounds.Width-1, e.Bounds.Height-1);
e.Graphics.DrawString(s1 , new Font("Ariel" ,9), new SolidBrush(Color.Black) , rc , sf );

if ( e.State == (DrawItemState.NoAccelerator | DrawItemState.Selected) ||
e.State == ( DrawItemState.NoAccelerator | DrawItemState.HotLight) )
{
System.Diagnostics.Debug.WriteLine("Inside");
e.Graphics.FillRectangle(new SolidBrush(Color.CornflowerBlue) , rc);
e.Graphics.DrawString( s1 , new Font("Veranda" , 10) , new SolidBrush(Color.Black), rc ,sf);
e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Black)), rc );
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top