> > Hi,
> > How do I add items in ListBox in VB.NET with the value;
[quoted text clipped - 7 lines]
> Regards,
> Petar Atanasovhttp://a-wake.net
What I'm trying to do is populate a name as display, but returning
selectedvalue upon click. With ListBox.Items.Add(name) only adds the
display value, not the selected value. isn't ToString is just what is
displayed?
Petar Atanasov - 30 May 2007 12:59 GMT
>>> Hi,
>>> How do I add items in ListBox in VB.NET with the value;
[quoted text clipped - 10 lines]
> display value, not the selected value. isn't ToString is just what is
> displayed?
hmm there is obvously something that I miss...
Does the ListBox.SelectedItem contain what you need ?
SelectedItem holds the item,
while SelectedIndex points to it's index in the collection.
OnClick you can capture them both and return, pass, etc. what's needed...
Regards,
Petar Atanasov
http://a-wake.net
Petar Atanasov - 30 May 2007 13:38 GMT
>>> Hi,
>>> How do I add items in ListBox in VB.NET with the value;
[quoted text clipped - 10 lines]
> display value, not the selected value. isn't ToString is just what is
> displayed?
hmm,
"...selectedvalue upon click..."
probably there is a misconseption with this property name.
It deals with ValueMember of ListControl not with the actually selected
Item (as you cen see in the Object Browser)...
Regards,
Petar Atanasov
http://a-wake.net
cerebellum - 31 May 2007 03:27 GMT
> >>> Hi,
> >>> How do I add items in ListBox in VB.NET with the value;
[quoted text clipped - 20 lines]
> Regards,
> Petar Atanasovhttp://a-wake.net
i want to set the value, not retrieve it. say that i have a table with
the fields userid.string and username.string and i want to put some
records into the table with the displayname: username. so i can handle
events (like click) to the appropriate userid with the SelectedValue
of the list.
I can do this using the data binding the control, but how do i do it
in code?
Petar Atanasov - 31 May 2007 15:22 GMT
>>>>> Hi,
>>>>> How do I add items in ListBox in VB.NET with the value;
[quoted text clipped - 26 lines]
> I can do this using the data binding the control, but how do i do it
> in code?
I don't see the reason of such approach, still more there is a plethora
of data toys - Dataset, Table, ArrayList, ListControl, etc.
Choose a tool, furnish it, than bind the control - couldn't be more neatly.
Regards,
Petar Atanasov
http://a-wake.net