private void Okay_Click(object sender, EventArgs e) { DepartmentInterface new_dept = listBox1.SelectedItem as DepartmentInterface; POSButtonInterface tmp_button = button; if (new_dept != dept) { tmp_button = new_dept.GetItemForButton(real_button); } if (tmp_button == null) { MessageBox.Show("Failed to get button from department"); } if (tmp_button.Configure()) { real_button.department = new_dept; real_button.button = tmp_button; this.DialogResult = DialogResult.OK; this.Close(); } else { } }