Hi ,
I am able to add Label, button,texboxes into Dictionary. However I am getting problem to add values of Combobox into dictionary. Here is how I was trying to do.
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
Try
Dim myLabel As Label
Dim myButton As Button
Dim myRadio As RadioButton
Dim myCombo As ComboBox = Nothing
_dic.Clear()
For Each ctl As Control In Me.Controls
If TypeOf ctl Is Label Then
myLabel = CType(ctl, Label)
_dic.Add(ctl.Name, myLabel.Text)
ElseIf TypeOf ctl Is Button Then
myButton = CType(ctl, Button)
_dic.Add(ctl.Name, myButton.Text)
ElseIf TypeOf ctl Is RadioButton Then
myRadio = CType(ctl, RadioButton)
_dic.Add(ctl.Name, myRadio.Text)
ElseIf TypeOf ctl Is ComboBox Then
myCombo = CType(ctl, ComboBox)
_dic.Add(ctl.Name, ComboBox1.SelectedItem)
End If
Next
For Each Item As KeyValuePair(Of String, String) In _dic
Debug.Print(Item.Key & " " & Item.Value)
Next
Catch ex As Exception
Debug.Print(ex.ToString)
End Try
End Sub
Would greatly appreciate your help.
Thanks.