private void button1_Click(object sender, EventArgs e) { if (text != null && listBox1.SelectedIndex != -1) { SeatPlan newForm = new SeatPlan(text, listBox1, names); newForm.Show(); } else { MessageBox.Show("Error\nA file was not opened or a course was not selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Warning); } }