0

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) & """")
2
Contributors
2
Replies
14
Views
4 Years
Discussion Span
Last Post by nikki05
0

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.

Edited by tinstaafl

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.