Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / May 2007

Tip: Looking for answers? Try searching our database.

Value in ListBox.Items.Add

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
cerebellum - 28 May 2007 08:47 GMT
Hi,
How do I add items in ListBox in VB.NET with the value;
ListBox.Items.Add("Text") only assign the text instead of the values.

Thnx
Petar Atanasov - 28 May 2007 12:09 GMT
> Hi,
> How do I add items in ListBox in VB.NET with the value;
> ListBox.Items.Add("Text") only assign the text instead of the values.
>
> Thnx

Hi, Cerebellum
Check the item property, e.g.: ListBox.Items.Item(lIdx).ToString

Regards,
Petar Atanasov
http://a-wake.net
cerebellum - 29 May 2007 02:24 GMT
> > 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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.