title: Get items and index of dynamic comboBox in VB.NET
body: <p>I have created a list of eight dynamic comboBoxes through the function combox1Gen() and then i have loaded items to them from a text file of values through function loadComboboxItems(). On every respective comboBox's item selection i need to display the value and its index. what code should in put inside ComboTName_SelectedIndexChanged()?
  One more issue is there. My comboBoxes with items get loaded very slowly in a hanging way. whats wrong with my code?
  My code is below:</p>
  
  <pre><code>Public ComboBoxesTname As New List(Of ComboBox)
  
  
         Dim i As Integer = 0
          Do While i &lt;= 7
              Combo1Gen(i)
              i = i + 1
          Loop
          loadComboboxItems()   
  
  
  
  Private Function Combo1Gen(ByVal n As Integer) As Boolean
          Try 
              Dim newCombo As New ComboBox
              With newCombo
                  .Name = "MyComboBox1" &amp; n.ToString
                  .Left = 110
                  .Top = 120 + (52 * n) + 20
                  .Width = 180
                  .Height = 20
                  .Visible = True
              End With
              ComboBoxesTname.Add(newCombo) 
              GroupBox1.Controls.Add(newCombo)
              GroupBox1.AutoSize = True
              AddHandler newCombo.SelectedIndexChanged, AddressOf ComboTName_SelectedIndexChanged
              Return True
          Catch ex As Exception
              MessageBox.Show(ex.ToString)
              Return False
          End Try
      End Function
  
         Private Function loadComboboxItems() As Boolean
          Try
  
              Dim listT As New List(Of String)()
              listT = ReadVars.readVars(GetFolderPath.GetFolderPath("\vars\"), "items.txt")
              For i = 0 To ComboBoxesTname.Count - 1
                  ComboBoxesTname(i).Items.AddRange(listT.ToArray)
              Next
              Return True
          Catch ex As Exception
              Debug.WriteLine(ex.ToString)
              MessageBox.Show("Error: " &amp; Err.ToString)
              Return False
          End Try
          Return False
      End Function
  
  Private Sub ComboTName_SelectedIndexChanged()
  
  End Sub
  </code></pre>