I am trying to loop through all the combo-boxes on my windows form VB.net application.
I had assumed this would work
Array.ForEach(Me.Controls.OfType(Of ComboBox).Items.Add(DataGridView1.Columns(i).Name)))
but I can not refer to the items it seems to not know it is a combobo at that point
I am trying to get a list of all my combobox names so i can hopefully use that list of names in a loop to add items and read the selected index but my list of names is always blank. I am using the following code just trying to send the list to a messgebox to see if it is grabbing any names.
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
Dim allComboBoxValues As String = ""
Dim c As Control
Dim childc As Control
For Each c In Me.Controls
For Each childc In c.Controls
If TypeOf childc Is ComboBox Then
allComboBoxValues &= CType(childc, ComboBox).Text & ","
End If
Next
Next
MsgBox(allComboBoxValues)
If allComboBoxValues <> "" Then
MsgBox(allComboBoxValues)
End If
End Sub