Hi
I am storing name and texts of controls (Label, Button, ComboBox, ListBox, etc.) into a dictionary.
With ContainsKey, I am able to find the texts of Labels, Buttons, and RadioButtons. However, I am getting problem to find the items of ComboBox. Appreciate if you have an idea.

 If _dic.ContainsKey(selectedControl.Name) Then
  Debug.Print("I found the text """ & _dic(selectedControl.Name) & """")

Try:

Dim TempComboBox As CombBox = DirectCast(Me.Controls(selectedControl.Name), ComboBox)
For Each item As String In TempComboBox.Items
    'Do Stuff
Next

On a side not, the same concept can be used for the 'Text' property without the need for a dictionary.

Thank you tinstaafl. It worked.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.