Eric,
What type of construct is mtTemplateNode?
Is it an object, a class, a form, a structure, a variable, something else?
If mtTemplateNode is the name of a class, you cannot (should not) add an
event at the class level to an instance method. You will get a null
reference exception when the event itself was raised.
Try
Dim node As New mtTemplateNode
ctxMenu.MenuItems.Add("Add new pattern...", AddressOf
node.cmdPatternAdd_Click)
ctxMenu.MenuItems.Add("Add new pattern...", New
System.EventHandler(AddressOf node.cmdPatternAdd_Click))
Notice that I am using an instance of the mtTemplateNode class for the event
handler.
Alternatively put Shared in front of the cmdPatternAdd_Click method.
Hope this helps
Jay
"Eric Newton" <er**@cc.ensoft-software.com> wrote in message
news:eX**************@TK2MSFTNGP11.phx.gbl... first line fails with "Reference to a non-shared member requires an object
reference."
yet second line works... any reasons?
ctxMenu.MenuItems.Add("Add new pattern...", AddressOf
mtTemplateNode.cmdPatternAdd_Click)
ctxMenu.MenuItems.Add("Add new pattern...", New
System.EventHandler(AddressOf mtTemplateNode.cmdPatternAdd_Click))
--
Eric Newton
C#/ASP Application Developer
http://ensoft-software.com/
er**@cc.ensoft-software.com [remove the first "CC."]