It works, I have moved everything what affect MainMenu to
InitializeComponent() :).

On 19 Wrz, 13:02, synesios <[EMAIL PROTECTED]> wrote:
> Hello!
> I would like to ask why MeasureItemEventHandler isn't rised in this
> code? (DrawItemEventHandler works OK).
>
> But when I create MainMenu and MenuItems objects directly in
> VisualStudio and add 'draw' and 'measure' handlers with VS Properties
> form, they work fine.
>
>         private MainMenu mm = new MainMenu();
>         private MenuItem mi1 = new MenuItem();
>         private MenuItem mi2 = new MenuItem();
>
>         private void Form1_Load(object sender, EventArgs e)
>         {
>             this.mi1.Text = "File";
>             this.mi1.Index = 0;
>
>             this.mi2.Text = "Window";
>             this.mi2.Index = 1;
>
>             this.mi1.OwnerDraw = true;
>             this.mi2.OwnerDraw = true;
>
>             this.mm.MenuItems.AddRange(new MenuItem[]{mi1, mi2});
>             this.Controls.Add(this.mm);
>             this.Menu = this.mm;
>
>             mi1.MeasureItem += new MeasureItemEventHandler(measure);
>             mi1.DrawItem += new DrawItemEventHandler(draw);
>         }
>
>         private void measure(object sender, MeasureItemEventArgs e)
>         {
>             e.ItemHeight = 20;
>             e.ItemWidth = 80;
>         }
>
>         private void draw(object sender, DrawItemEventArgs e)
>         {
>             Rectangle rec = new Rectangle(e.Bounds.X, e.Bounds.Y,
> e.Bounds.Width, e.Bounds.Height);
>             e.Graphics.DrawRectangle(new Pen(Color.Black), rec);
>         }
>
> Best Regards
> S.

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web 
Services,.NET Remoting" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://cm.megasolutions.net/forums/default.aspx
-~----------~----~----~----~------~----~------~--~---

Reply via email to