Hi Team,
I need the values of the textbox to be moved to Listbutton on button click.( Buton and Listbox are created manually).
For your information i have created textboxes dynamically on form run. I need those values to be sent to listbox.
My code is below
Dim but As Button = Nothing
Dim but2 As Button = Nothing
Dim but3 As Button = Nothing
Dim supbut As Button = Nothing
Dim supbut2 As Button = Nothing
Dim suptxt As TextBox = Nothing
Dim abbut As Button = Nothing
Dim abbut2 As Button = Nothing
Dim abtxt As TextBox = Nothing
Dim inbut As Button = Nothing
Dim inbut2 As Button = Nothing
Dim intxt As TextBox = Nothing
Dim lbl As Label = Nothing
For Me.i = 1 To ListBox1.Items.Count
but = New Button
With but
.Location = New Point(500, 150 + (i * 25))
.Tag = i.ToString
.Name = "Button" & i
.Width = 24
.Text = "+"
.Parent = Me
AddHandler but.Click, AddressOf oBtn_Click
End With
txt = New TextBox
With txt
.Location = New Point(545, 150 + (i * 25))
.Tag = i.ToString
.Name = "TextBox" & i
.Width = 24
.Parent = Me
End With
but2 = New Button
With but2
.Location = New Point(590, 150 + (i * 25))
.Tag = i.ToString
.Name = "Button" & i
.Width = 24
.Text = "-"
.Parent = Me
AddHandler but2.Click, AddressOf oBtn2_Click
End With
Next i
For Me.j = 1 To ListBox1.Items.Count
supbut = New Button
With supbut
.Location = New Point(670, 150 + (j * 25))
.Tag = j.ToString
.Name = "Button" & j
.Width = 24
.Text = "+"
.Parent = Me
AddHandler supbut.Click, AddressOf osupBtn_Click
End With
suptxt = New TextBox
With suptxt
.Location = New Point(715, 150 + (j * 25))
.Tag = j.ToString
.Name = "SupTextBox" & j
.Width = 24
.Parent = Me
End With
supbut2 = New Button
With supbut2
.Location = New Point(760, 150 + (j * 25))
.Tag = j.ToString
.Name = "Button" & j
.Width = 24
.Text = "-"
.Parent = Me
AddHandler supbut2.Click, AddressOf osupBtn2_Click
End With
Next j
For Me.k = 1 To ListBox1.Items.Count
abbut = New Button
With abbut
.Location = New Point(840, 150 + (k * 25))
.Tag = k.ToString
.Name = "Button" & k
.Width = 24
.Text = "+"
.Parent = Me
End With
abtxt = New TextBox
With abtxt
.Location = New Point(885, 150 + (k * 25))
.Name = "TextBox" & k
.Width = 24
.Tag = k.ToString
.Parent = Me
End With
abbut2 = New Button
With abbut2
.Location = New Point(930, 150 + (k * 25))
.Tag = k.ToString
.Name = "Button" & k
.Width = 24
.Text = "-"
.Parent = Me
End With
Next k
For l = 1 To ListBox1.Items.Count
inbut = New Button
With inbut
.Location = New Point(1010, 150 + (l * 25))
.Tag = l.ToString
.Name = "Button" & l
.Width = 24
.Text = "+"
.Parent = Me
End With
intxt = New TextBox
With intxt
.Location = New Point(1055, 150 + (l * 25))
.Name = "TextBox" & l
.Width = 24
.Tag = l.ToString
.Parent = Me
End With
inbut2 = New Button
With inbut2
.Location = New Point(1095, 150 + (l * 25))
.Tag = l.ToString
.Name = "Button" & l
.Width = 24
.Text = "-"
.Parent = Me
End With
Next l
End Sub
listbox display snippet
Dim ctl As Control = Me.GetNextControl(Me, True)
Do
If ctl Is txt Then
ListBox2.Items.Add(ctl.Text)
End If
ctl = Me.GetNextControl(ctl, True)
Loop Until ctl Is txt
ListBox2.Items.Add(txt.Text)
the listbox snippet works, but ts getting all text box values to listbox. i need to add only the particular set of textbox's value to one listbox and others in separate listbox.
Listbox2 Listbox3
but text but but text but
but text but but text but
but text but but text but
but text but but text but