|
-
Dec 30th, 2005, 06:02 AM
#1
Thread Starter
Addicted Member
Last edited by Waseemalisyed; Jan 2nd, 2006 at 11:57 PM.
-
Dec 30th, 2005, 08:24 PM
#2
New Member
Re: Solve Listbox Problem
Edit: Added tags for clarity. - Hack
...Didn't help. I'm still confused.
1 3/-\7 n00b5 |=0|2 1|_|/\/{# - pwn
Social Engineering Specialist--because there is no patch for human stupidity.
CARPE NOCTEM - yeeeahh baab1e! - The Jargon File ©wr1te
-
Jan 22nd, 2006, 04:21 AM
#3
Hyperactive Member
Re: Screen Pictur is Attached
lstSelectedBen.Items.Add(lstAvailBen.SelectedItem.ToString());
-
Jan 22nd, 2006, 07:25 AM
#4
Re: Screen Pictur is Attached
 Originally Posted by wordracr
lstSelectedBen.Items.Add(lstAvailBen.SelectedItem.ToString());
That won't work. You have bound the first ListBox to a DataTable so each item is a DataRowView. You can't just add a DataRowView to another ListBox, and calling ToString on it will just return "System.Data.DataRowView". What you want is:
Code:
lstSelectedBen.Items.Add(lstAvailBen.GetItemText(lstAvailBen.SelectedItem))
which will actually get the text displayed in the control for that item. When getting the actual string displayed for an item in a ListBox or ComboBox you should make a habit of ALWAYS using GetItemText. That way you can never go wrong, regardless of what type of objects the ListControl contains.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|