ItemData equivalent .NET

  • Thread starter Thread starter Sivaprasad
  • Start date Start date
S

Sivaprasad

Hi All,

Can anybody tell me what is the "itemdata" in Combo box of VB6 equivalent in
..VB.Net.
Like we do in VB 6, I want to retrieve the id of the selected item from a
combo box.

I tried "Selected Item", "Selected Index","Selected Value".
none of these gives my result.

Thanks
Siva
 
Sivaprasad said:
Can anybody tell me what is the "itemdata" in Combo box of VB6
equivalent in .VB.Net.
Like we do in VB 6, I want to retrieve the id of the selected item
from a combo box.

I tried "Selected Item", "Selected Index","Selected Value".
none of these gives my result.

Now you are not limited to two values (text+itemdata) anymore. You can add
any object to the combo box. The return value of the objects' string values
are shown in the combo.
 
Thanks for this link.
According to this example, the combo box will show the whole content in the
class right? eg: Name and Age.
If I want to show only the name and when the user select this I want to get
the Age.How do i get it?

Thanks again
Siva
 
* "Sivaprasad said:
Thanks for this link.
According to this example, the combo box will show the whole content in the
class right? eg: Name and Age.
If I want to show only the name and when the user select this I want to get
the Age.How do i get it?

You will have to change the 'ToString' method's implementation in order
to return the name only.

Later in the code you can access items like this:

\\\
MsgBox(DirectCast(Me.ListBox1.SelectedItem, Person).Age.ToString())
///
 
Ok,
Thanks for the tips


Herfried K. Wagner said:
You will have to change the 'ToString' method's implementation in order
to return the name only.

Later in the code you can access items like this:

\\\
MsgBox(DirectCast(Me.ListBox1.SelectedItem, Person).Age.ToString())
///
 
Back
Top