0
Answer

How do I make MenuItems now show arrow image if it has submenu.

Ask a question
Hai all, Somebody help me in this issue. I need to have a menu bar which is RightToLeft aligned, which I can achieve by setting MainMenu's RightToLeft property to "Yes". The problem that I get is, if one of MenuItems has submenu...the arrow(or small triangle which indiates it has submenu) appears in the left. I wanted to know when is this getting drawn. I want to trap that and draw my own image to indicate that it has submenu. Below is the code that I have written for DrawItem handler for each MenuItem. Any help is greatly appreciated..... Thanks, Madhavi. private void menuItem2_DrawItem(object sender, System.Windows.Forms.DrawItemEventArgs e) { // Rectangle rc = new Rectangle(e.Bounds.X+delta , e.Bounds.Y+delta, e.Bounds.Width-delta, e.Bounds.Height-delta); System.Windows.Forms.Label lbl = new Label(); Rectangle rc = new Rectangle(e.Bounds.X, e.Bounds.Y, e.Bounds.Width, e.Bounds.Height); e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(204, 204, 204)) , rc); //e.Graphics. MenuItem s = (MenuItem)sender ; string s1 = s.Text ; StringFormat sf = new StringFormat(); sf.Alignment = StringAlignment.Center ; sf.LineAlignment = StringAlignment.Center; Rectangle rcText = rc ; rcText.Width-=1 ; rcText.Height -= 2; //e.Graphics.FillRectangle(new SolidBrush(Color.LightGray) e.Graphics.DrawString(s1 , new Font("Arial" ,9), new SolidBrush(Color.Black) , rcText, sf ); e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Gray)), rcText ); if ( e.State == ( DrawItemState.NoAccelerator | DrawItemState.HotLight) || e.State == ( DrawItemState.NoAccelerator | DrawItemState.Selected)) { e.Graphics.FillRectangle(new SolidBrush(Color.FromArgb(255,255,128)) , rcText); e.Graphics.DrawString( s1 , new Font("Arial" , 9 ) , new SolidBrush(Color.Black), rcText,sf); e.Graphics.DrawRectangle(new Pen(new SolidBrush(Color.Gray)), rcText ); e.DrawFocusRectangle(); } }