|
-
January 12th, 2009, 06:26 PM
#1
databound listbox problem
Hi, i'm currently doing a uni project and I'm having a bit of trouble with a databound listbox.
Basically it's two listboxs, listbox1 is databound to a access database and it's getting the information fine
what i'm trying to achieve is that when you select an item from the listbox1 it is added to listbox2.
So far when the you select the item from listbox1, the index number of the selected item is added to listbox 2,
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBox1.SelectedIndex != -1)
{
// int x = listBox1.SelectedIndex;
{
// string orderitem = Convert.ToString(listBox1.Items[x]);
listBox3.Items.Add(listBox1.SelectedIndex);
}
}
}
any ideas how i can get the actually information added?
the two lines i have commented out where just an idea i had, which didn't work
cheers, Scott
-
January 12th, 2009, 06:55 PM
#2
Re: databound listbox problem
Code:
listBox3.Items.Add(listBox1.Items[listbox1.SelectedIndex]));
This is not a great design, but your does not work because you are trying to add an integer to a collection of ListViewItems.
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
|