/// <summary> /// Creates a new dialog object and shows it to the user. After making the selections, the values in the main dialog are updated with them. /// </summary> private void openTentDialog(UserInterface.Tent tent) { var tentDialog = new AddTentDlg(tent); tentDialog.ShowDialog(); if (tentDialog.Code == true) { this.tentDGV.Rows.Add(); this.tentDGV.Rows[TentCtr].Cells[0].Value = tentDialog.TypeOfTent; this.tentDGV.Rows[TentCtr].Cells[1].Value = tentDialog.TentSize; this.tentDGV.Rows[TentCtr].Cells[2].Value = tentDialog.Qty.ToString(); this.tentDGV.Rows[TentCtr].Cells[3].Value = tentDialog.CoverType; this.tentDGV.Rows[TentCtr].Cells[4].Value = tentDialog.TieDown; this.tentDGV.Rows[TentCtr].Cells[5].Value = tentDialog.Walls; this.tentDGV.Rows[TentCtr].Cells[6].Value = tentDialog.Legs; TentCtr++; } UpdateList(); }
private void editRowToolStripMenuItem_Click(object sender, EventArgs e) { // Get index of selected row int selectedRowIndex = tentDGV.SelectedCells[0].RowIndex; // Get the type of tent (enum) Tent typeOfTent = (UserInterface.Tent)tentDGV.Rows[selectedRowIndex].Cells[0].Value; // Create new object of AddTentDlg class var TentDLG = new AddTentDlg(typeOfTent) { // Set properties of object according to values in selected row TentSize = this.tentDGV.Rows[selectedRowIndex].Cells[1].Value.ToString(), Qty = Convert.ToDecimal(this.tentDGV.Rows[selectedRowIndex].Cells[2].Value), CoverType = this.tentDGV.Rows[selectedRowIndex].Cells[3].Value.ToString(), TieDown = this.tentDGV.Rows[selectedRowIndex].Cells[4].Value.ToString(), Walls = this.tentDGV.Rows[selectedRowIndex].Cells[5].Value.ToString(), Legs = this.tentDGV.Rows[selectedRowIndex].Cells[6].Value.ToString() }; // Update the Dialog with these values TentDLG.UpdateFields(); // Show the Dialog TentDLG.StartPosition = FormStartPosition.Manual; TentDLG.Location = new Point(100, 100); if (TentDLG.ShowDialog() == DialogResult.OK) { // Update Main Dialog with new values this.tentDGV.Rows[selectedRowIndex].Cells[0].Value = typeOfTent; this.tentDGV.Rows[selectedRowIndex].Cells[1].Value = TentDLG.TentSize; this.tentDGV.Rows[selectedRowIndex].Cells[2].Value = TentDLG.Qty.ToString(); this.tentDGV.Rows[selectedRowIndex].Cells[3].Value = TentDLG.CoverType; this.tentDGV.Rows[selectedRowIndex].Cells[4].Value = TentDLG.TieDown; this.tentDGV.Rows[selectedRowIndex].Cells[5].Value = TentDLG.Walls; this.tentDGV.Rows[selectedRowIndex].Cells[6].Value = TentDLG.Legs; // Update the list of items UpdateList(); } }