一、DataGridView的事件
1)CellDoubleClick
/// <summary>
/// 双击表格时候发生
/// </summary>
private void dgvList_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
{
var row = dgvList.Rows[e.RowIndex];
txtID.Text = row.Cells[0].Value.ToString();
txtname.Text = row.Cells[1].Value.ToString();
cmbClass.Text = Convert.ToString(row.Cells[2].Value);
txtPrice.Text = row.Cells[3].Value.ToString();
txtname.Enabled = false;
btnAdd.Text = "修改";
}
2)CellEndEdit
/// <summary>
/// 当前选中单元编辑模式停止的时候发生
/// </summary>
private void dgvList_CellEndEdit(object sender, DataGridViewCellEventArgs e)
{
try
{
//选中单元格
var row = dgvSelectOrder.Rows[e.RowIndex]