private void Load_Click(object sender, EventArgs e) { PortEntry pe = null; DataGridViewRow item_f = null; int i = -1; foreach (DataGridViewRow item in dataGridView1.SelectedRows) { i = (int)item.Cells["Index"].Value; pe = Ports[i]; item_f = item; break; } if (pe == null) { MessageBox.Show("Please select a port in order to edit"); return; } string name = PortNameText.Text; if (!pe.GetName().Equals(name)) { MessageBox.Show("You can't edit a port's name"); PortNameText.Text = pe.GetName(); return; } string memory_size = MemorySizeText.Text; bool valid = ValidCheckBox.Checked; char r_w = R_WCombo.SelectedItem.ToString()[0]; bool relative_address = RelativeAddressCheckBox.Checked; char emergency_enable = 'N'; if (EmergencyCheckBox.Checked) { emergency_enable = 'Y'; } bool debug_enable = DebugCheckBox.Checked; int priority = (int)numericUpDown1.Value; int memory_section = (int)numericUpDown2.Value; int data_size = int.Parse(DataSizeBox.SelectedItem.ToString()); char bank = BankBox.SelectedItem.ToString()[0]; string comment = CommentText.Text; p_type type = (p_type)Enum.Parse(typeof(p_type), TypeOpts.Text, true); if (i == -1) { MessageBox.Show("No such port " + name); InitFields(); return; } if (pe.GetIsComment()) { MessageBox.Show("This port is a comment and can't be edited"); //InitFields(); return; } pe.EditPort(valid, type, r_w, data_size, bank, memory_size, memory_section, relative_address, priority, emergency_enable, debug_enable, comment); OpenValidation(); UpdateDataBase(); EditCell(item_f, pe.GetTableEntry()); //MessageBox.Show(pe.ToString()); saved = false; }