ItemData equivalent .NET

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
 
A

Armin Zingler

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.
 
S

Sivaprasad

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
 
H

Herfried K. Wagner [MVP]

* "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())
///
 
S

Sivaprasad

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())
///
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top