I'm trying to dynamically add a menuitem to my context menu and add a click handler but for some reason it won't add the handler what did a do wrong?
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click For Each Line In RichTextBox1.Lines Dim NewItem As New MenuItem NewItem.Text = Line AddHandler NewItem.Click, AddressOf NewItem_Click ContextMenuStrip1.Items.Add(Line) Next End Sub Private Sub NewItem_Click(sender As Object, e As EventArgs) MsgBox(CType(sender, MenuItem).Text) End Sub
Dim NewItem As ToolStripMenuItem = New ToolStripMenuItem NewItem.Text = Line AddHandler NewItem.Click, AddressOf NewItem_Click ContextMenuStrip1.Items.Add(NewItem)
Edited by tinstaafl
maybe try firts to debug your codes to see what is the problem.
Hi, I have been given a project to finish in school in 3 phases, the thing is I am not that good when it comes to programing. The project was ...
hi james cherril
I am doing a voting system application of which I have to hand up today. I am getting a runtime error when I entered a record and ...
Good man James helped me learn die roll board game programming in Java,
and I applied it on Ladders and Snakes. Made one in Java. Now I'm learning to do ...