Add multiple items from ListBox to TextBox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • buterfly0707
    New Member
    • Nov 2009
    • 30

    Add multiple items from ListBox to TextBox

    hi..

    i want to add selected multiple items form list box to text box(MultiLine) seperated with a comma in each item.I know how to add multiple list box values to another List box. but how can i add for the text box.

    it will be a grate help if some one can help me with this.
    thank you.
  • ThatThatGuy
    Recognized Expert Contributor
    • Jul 2009
    • 453

    #2
    on mouse click or double click event of the ListBox write this code....

    Code:
    TextBox1.Text+=ListBox1.SelectedItem.ToString()+", ";

    Comment

    • buterfly0707
      New Member
      • Nov 2009
      • 30

      #3
      Thank you very much. it worked...

      Comment

      • tlhintoq
        Recognized Expert Specialist
        • Mar 2008
        • 3532

        #4
        I think that will give you problems.

        What happens when someone control+click an item to de-select it? It won't come off your textbox.

        Or click on the top item then shift+click the last time to select everything in between.

        I think you would be better off activating against the listbox .SelectedIndexe sChanged event. Then loop through the selecteditems collection.

        Comment

        Working...