private void 编辑ToolStripMenuItem_Click(object sender, EventArgs e) { DataGridView datadridView = this.panel1.Controls[0].Controls[0] as DataGridView; if (datadridView[0, datadridView.CurrentCell.RowIndex].Value != null) { GoodsEditor editor = new GoodsEditor(int.Parse(datadridView[0, datadridView.CurrentCell.RowIndex].Value.ToString())); editor.GoodsAbilitysChanged += Editor_GoodsAbilitysChanged; editor.ShowDialog(); } }
/// <summary> /// 双击一个单元格时显示该物品的详细信息 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { try { int id = int.Parse(dataGridView1[0, e.RowIndex].Value.ToString()); GoodsEditor itemEditor = new GoodsEditor(id); itemEditor.ShowDialog(); } catch { MessageBox.Show("未能正确获取到指定物品ID,请检查后重试"); } }
/// <summary> /// 详细编辑 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DataGridView1_CellMouseDoubleClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.ColumnIndex == 0 && e.RowIndex >= 0 && e.RowIndex < dataGridView1.RowCount) { if (dataGridView1[0, e.RowIndex].Value == null) { return; } int id = int.Parse(dataGridView1[0, e.RowIndex].Value.ToString()); GoodsEditor itemEditor = new GoodsEditor(id); itemEditor.GoodsAbilitysChanged += ItemEditor_GoodsAbilitysChanged; itemEditor.ShowDialog(); } }