Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Ok, here's the situation. My program creates in code a context menu called mnuContextMenu, to which I add menuitems with code like mnuContextMenu.MenuItems.Add(txt.Text).

 

I want all of the items in this context menu to do the same things when clicked, namely copy the text of the menuitem to the clipboard. I know how to copy things to the clipboard, what I don't know how to do is create an event handler for these programmatically-added menuItems. Please help! Thanks.

Posted

you can try someing like this:

Me.MenuItem2.Index = 0
Me.MenuItem2.MenuItems.AddRange(New System.Windows.Forms.MenuItem() )
Me.MenuItem2.Text = "Enter Text"

i dont know if it will work but try that

  • *Experts*
Posted

AddHandler object.Event, AddressOf handlersub

Where handlersub is the sub that will handle the event, it must also accept arguments that correspond to the event.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...