CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2009
    Posts
    3

    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

  2. #2
    Join Date
    Jun 2008
    Posts
    2,477

    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
  •  





Click Here to Expand Forum to Full Width

Featured