简体   繁体   中英

Send data from a listbox to a label on another form

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.

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(); } } 

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM