0

I have a menu where I can add items to a list box using an add button.

I then have a button to send the order so to speak.

The button to send the order I need it to be able to send what is in the list box to a label (or even list box?) on another form.

So far I am only able to write my own text in a text box and then send it to a label on another form, I can't work out how to use what is in the list box to send to that label.

Padgey85
  • 211
  • 1
  • 2
  • 7
  • Possible duplicate of [Send values from one form to another form](http://stackoverflow.com/questions/1559770/send-values-from-one-form-to-another-form). Such questions should be nominated as **the most often asked questions without using search**. – Sinatr Oct 22 '15 at 12:01

1 Answers1

1

You can do it like this:

  • In your first form with the listbox

    Form2 f = new Form2(listBox1);
    f.Show();
    
  • In second form with label

    public Form2(ListBox listy)
    {
        InitializeComponent();
    
         foreach (var item in listy.Items)
         {
            label1.Text += item.ToString();
         }
     }
    
Slyvain
  • 1,732
  • 3
  • 23
  • 27
ian korkie
  • 53
  • 1
  • 8
  • Thanks this worked a treat, however when I add to the label it is coming up like 'ItemItemItemItem' where as I need them on seperate lines as it is an order confirmation I am trying to do. – Padgey85 Nov 06 '15 at 13:45