rickb
Freshman
Here's what I have and what I want to do: On a form, I have a listview, a context menu (cmSouth) and a series of textboxes in a groupbox. The context menu is linked to the listview. What I want to happen is, when i right-click on an item in the listview, I want to move that item to the next empty textbox in the groupbox named after the contextmenu item that is clicked.
Here is the code I've been playing with:
None of this works, and I'm sure the code isn't even close to being able to work. I would appreciate any guidance.
Here is the code I've been playing with:
Code:
Private Sub TextboxList()
Dim i As Integer = 0
Dim ctrl As Control
For Each ctrl In Me.Controls
If TypeOf ctrl Is TextBox Then
dragbox = DirectCast(ctrl, TextBox)
If dragbox.Name = "Textbox" & i.ToString Then
If dragbox.TextLength = "" Then
i += 1
dragbox.Text = Me.ListView1.SelectedItems(0).Text.ToString
'The below line is commented out because I've been trying different things and I didn't want to delete it.
'AddHandler cmSouth.Click, AddressOf cmSouth_Click
End If
End If
End If
Next ctrl
End Sub
Private Sub cmSouth_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim dragbox() As TextBox = {TextBox1, TextBox2,TextBox3,Textbox4}
dragbox(i).Text = Me.ListView1.SelectedItems(0).Text.ToString
'This is left over from when I was trying to do this with the listbox.
Me.ListBox1.Items.Add(Me.ListView1.SelectedItems(0).Text).ToString()
End Sub
None of this works, and I'm sure the code isn't even close to being able to work. I would appreciate any guidance.