private int AddGridItem() { string cmd; string name; int index; NewCmdForm addForm = new NewCmdForm(); //addForm.Owner = this; //addForm.Parent = mainForm.Parent; if (addForm.ShowDialog() == DialogResult.OK) { cmd = addForm.GetNewCmd(); name = addForm.GetNewCmdName(); if (null == cmd || 0 == cmd.Length) { ShowInfo("Null Cmd", ErrorType.ERROR); return(-1); } index = gridCmdList.Rows.Add(); gridCmdList.Rows[index].Cells[1].Value = cmd; if (null == name || 0 == name.Length) { ShowInfo("Not Add Cmd Discription", ErrorType.WARNING); gridCmdList.Rows[index].Cells[1].ToolTipText = "No Discription"; } else { gridCmdList.Rows[index].Cells[1].ToolTipText = name; ShowInfo("A New Cmd Added", ErrorType.INFO); } } return(0); }
private int LoadGridItem() { string cmd = null; string name = null; //int index; NewCmdForm addForm = new NewCmdForm(); DataGridViewRow row = gridCmdList.CurrentRow; if (null == row) { return(-1); } //foreach (DataGridViewRow row in gridCmdList.SelectedRows) //{ cmd = (string)row.Cells[1].Value; name = row.Cells[1].ToolTipText; // break; //} addForm.SetNewCmd(cmd); addForm.SetNewCmdName(name); if (addForm.ShowDialog() == DialogResult.OK) { cmd = addForm.GetNewCmd(); name = addForm.GetNewCmdName(); if (null == cmd || 0 == cmd.Length) { ShowInfo("Null Cmd", ErrorType.ERROR); return(-1); } //index = gridCmdList.Rows.Add(); row.Cells[1].Value = cmd; if (null == name || 0 == name.Length) { ShowInfo("Not Add Cmd Discription", ErrorType.WARNING); row.Cells[1].ToolTipText = "No Discription"; } else { DataGridViewCheckBoxCell checkCell = (DataGridViewCheckBoxCell)row.Cells["ColumnEdit"]; checkCell.Value = false; row.Cells[1].ToolTipText = name; ShowInfo("Cmd had modify success", ErrorType.INFO); } } return(0); }