I
Ing. Rajesh Kumar
Hi everybody
I am a web developer now trying to do something in WinForms using VB.NET and
have a small problem with ComboBox. I just wanted to ask what is the
equivalent to the following web code :
Dim MyString as String
Do While DR.Read()
Select Case DR("Column_1")
Case "X" : MyString = "XXXX"
Case Else : MyString = DR("Column_1")
End Select
DropDownList1.Items.Add(New ListItem(MyString, DR("Column_2")))
Loop
'Could also be : For i = 0 To 5 and then DropDownList1.Items.Add(New
ListItem("Item " & i, i))
In WinForms i can add only one item as :
DropDownList1.Items.Add("XXXX")
but i need to add KEY and VALUE.
I read a lot in the MSDN and found a way to do this using dataset,
DisplayMember, ValueMember and a helper class but not an easy way.
Thanks in advace
Raja
I am a web developer now trying to do something in WinForms using VB.NET and
have a small problem with ComboBox. I just wanted to ask what is the
equivalent to the following web code :
Dim MyString as String
Do While DR.Read()
Select Case DR("Column_1")
Case "X" : MyString = "XXXX"
Case Else : MyString = DR("Column_1")
End Select
DropDownList1.Items.Add(New ListItem(MyString, DR("Column_2")))
Loop
'Could also be : For i = 0 To 5 and then DropDownList1.Items.Add(New
ListItem("Item " & i, i))
In WinForms i can add only one item as :
DropDownList1.Items.Add("XXXX")
but i need to add KEY and VALUE.
I read a lot in the MSDN and found a way to do this using dataset,
DisplayMember, ValueMember and a helper class but not an easy way.
Thanks in advace
Raja