Cumstomizable Mainmenu: how to add the events C#s vs VB.NET
-
Hi, I am trying to convert the code in this document: http://www.codeproject.com/cs/miscctrl/custommenu.asp[^] into VB.net instead of C#. I have got most of it done but I am missing the final step, or at least I hope it is the final step. In the article all the menuitems have the following two events added: this.menuItem3.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.OnDrawItemSec); this.menuItem3.MeasureItem += new System.Windows.Forms.MeasureItemEventHandler(this.OnMeasureItemSec); When I look at the source article used for this article, the author writes about going to the eventtab on each menuitem. I am guessing this is typically C# as I cannot find it in VB.net. So can anyone please tell me how to do this? Thanks David J Think, try, think, think, try, think, think, think, try, ASK, think, try, advance on step and start over...
-
Hi, I am trying to convert the code in this document: http://www.codeproject.com/cs/miscctrl/custommenu.asp[^] into VB.net instead of C#. I have got most of it done but I am missing the final step, or at least I hope it is the final step. In the article all the menuitems have the following two events added: this.menuItem3.DrawItem += new System.Windows.Forms.DrawItemEventHandler(this.OnDrawItemSec); this.menuItem3.MeasureItem += new System.Windows.Forms.MeasureItemEventHandler(this.OnMeasureItemSec); When I look at the source article used for this article, the author writes about going to the eventtab on each menuitem. I am guessing this is typically C# as I cannot find it in VB.net. So can anyone please tell me how to do this? Thanks David J Think, try, think, think, try, think, think, think, try, ASK, think, try, advance on step and start over...
Your are looking for the AddHandler statement: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vastmAddHandlerStatement.asp For your example:
AddHandler Me.menuItem3.DrawItem, AddressOf Me.OnDrawItemSec AddHandler Me.menuItem3.MeasureItem, AddressOf Me.OnMeasureItemSec