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 );
}
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 );
}