Passing data between forms

Try adding a parameter to the constructor of the second form (in your example, Form1) and passing the value that way. Once InitializeComponent() is called you can then add the parameter to the listbox as a choice.

public Form1(String customItem)
{
  InitializeComponent();
  this.myListBox.Items.Add(customItem);
}

// In the original form's code:
Form1 frm = new Form1(this.textBox.Text);

Leave a Comment