private void newButton_Button_Pressed(object sender, EventArgs e) { Institution_Form showForm = new Institution_Form(); if (showForm.ShowDialog() == DialogResult.OK) { if ((showForm.Code.Length > 0) && (showForm.Institution_Name.Length > 0)) { listView1.Items.Add(new ListViewItem(new string[2] { showForm.Code, showForm.Institution_Name })); } else { MessageBox.Show("Institutions require both a code/abbreviation and an institutional name", "Invalid Entry", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }
private void editButton_Button_Pressed(object sender, EventArgs e) { if (listView1.SelectedItems.Count > 0) { Institution_Form showForm = new Institution_Form(listView1.SelectedItems[0].SubItems[0].Text, listView1.SelectedItems[0].SubItems[1].Text); if (showForm.ShowDialog() == DialogResult.OK) { if ((showForm.Code.Length > 0) && (showForm.Institution_Name.Length > 0)) { listView1.SelectedItems[0].SubItems[0].Text = showForm.Code; listView1.SelectedItems[0].SubItems[1].Text = showForm.Institution_Name; } else { MessageBox.Show("Institutions require both a code/abbreviation and an institutional name", "Invalid Entry", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }