1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to transfer Multiple listbox text to another listbox using C#.net

Discussion in 'Programming' started by ManiRai, Apr 16, 2010.

  1. #1
    How to transfer Multiple listbox text to another listbox using C#.net

    please tell me how to do it asap.....
     
    ManiRai, Apr 16, 2010 IP
  2. ccoonen

    ccoonen Well-Known Member

    Messages:
    1,606
    Likes Received:
    71
    Best Answers:
    0
    Trophy Points:
    160
    #2
    listBox1.Items.Add("hello");
    listBox1.Items.Add("world");
    foreach (string item in listBox1.Items)
    listBox2.Items.Add(item);
     
    ccoonen, Apr 16, 2010 IP
  3. ManiRai

    ManiRai Peon

    Messages:
    7
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I want data to be binded from database for one listbox and transfer to another listbox by selecting multiple text
    plz help...
     
    ManiRai, Apr 16, 2010 IP
  4. intizam

    intizam Member

    Messages:
    151
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    28
    #4
    If you are using databound listbox dont directly bound listbox to dataset / datable, the best option is populate an ArrayList with dataset and bound listbox with arraylist it is easy to remove and add items in arraylist and its effect is automatically shown in listbox
     
    intizam, Apr 16, 2010 IP
  5. NeoCambell

    NeoCambell Peon

    Messages:
    456
    Likes Received:
    6
    Best Answers:
    0
    Trophy Points:
    0
    #5
    According my understanding, you have one list box populated from database. And you select multiple items from that and you want those to be moved to another list box. Is that what you want? If so, you can use following code.

    foreach (ListItem Item in ListBox.Items) { 
        if (Item.Selected == true) {
             listBox2.Items.Add(Item.Text); 
        } 
    }
    Code (markup):
     
    NeoCambell, Apr 18, 2010 IP