I'm having a problem using arrays in VB.NET.Â
Here's the thing:
This is the initial design of the form during design time. What I want to do is repeatedly create a combo box and a text box for every row in list view.
Here's how it looks like at runtime; since there are two items in list view, there will be two combo boxes and two text boxes:
Now here's where I lost it: the text of the text box will depend on the item chosen from the combo box. Say, if Good is selected from the combo box, $10 should be placed in the text box. What happens is that when I choose Good from the second combo box, the $10 still appears in the first textbox. This, I think, is where I lost it. The $10 appears on the  first textbox because I wrote TextBox1.Text = $10; what should I write to call the second text box(created dynamically in runtime)?
Â
    If cbo.Text = "Good" Then
      TextBox1.Text = "$10"
    End If
Â
Here's the whole code, take a look:
Public comboarr() As ComboBox, textarr() As TextBox
  Private Sub Form5_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    MS_ListviewSetting(ListView1)
    ListView1.Columns.Add("Name")
    ListView1.Columns.Add("Contact")
    Dim lvitem As New ListViewItem
    lvitem.Text = "AA"
    lvitem.SubItems.Add("aa")
Â
    Dim lvitem1 As New ListViewItem
    lvitem1.Text = "BB"
    lvitem1.SubItems.Add("bb")
    ListView1.Items.Add(lvitem)
    ListView1.Items.Add(lvitem1)
    ReDim comboarr(ListView1.Items.Count)
    ReDim textarr(ListView1.Items.Count)
    comboarr(0) = ComboBox1
    textarr(0) = TextBox1
    loadData()
    ComboBox1.Items.Add("Good")
    ComboBox1.Items.Add("Lost")
    ComboBox1.Items.Add("Damaged")
  End Sub
  Sub loadData()
    For i = 1 To ListView1.Items.Count – 1
      Dim btn As New ComboBox()
      comboarr(i) = btn
      btn.Location = New System.Drawing.Point(comboarr(i – 1).Location.X, comboarr(i – 1).Location.Y + 20)
      btn.Size = New System.Drawing.Size(ComboBox1.Size)
      btn.DropDownStyle = ComboBoxStyle.DropDownList
      btn.Items.Add("Good")
      btn.Items.Add("Lost")
      btn.Items.Add("Damaged")
      btn.SelectedIndex = 0
      Me.Controls.Add(btn)
      AddHandler btn.Click, AddressOf Me.ClickButton
Â
      Dim lbl As New TextBox()
      textarr(i) = TextBox1
      lbl.Location = New System.Drawing.Point(textarr(i – 1).Location.X, textarr(i – 1).Location.Y + 20)
      lbl.Size = New System.Drawing.Size(TextBox1.Size)
      Me.Controls.Add(lbl)
    Next
  End Sub
  Private Sub ClickButton(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ComboBox1.Click
    Dim cbo As ComboBox
    cbo = CType(sender, ComboBox)
    '  MsgBox(btn.Text)
    If cbo.Text = "Good" Then
      TextBox1.Text = "$10"
    End If
  End Sub