1. 添加ContextMenuStrip快捷菜单控件this
2. 添加ContextMenuStrip事件orm
3. DataGridView 右键属性关联ContextMenuStrip事件
bool isChecked = true;ip
if (this.dataGridView1.Rows != null)
{
for (int i = 0; i < this.dataGridView1.Rows.Count; i++)
{
if (dataGridView1.Rows[i].Selected == true) //该行是否选中
{
this.dataGridView1.Rows[i].Cells[0].Value = isChecked; //勾选改行复选框
}
}
this.dataGridView1.RefreshEdit();
}it
添加事件di
this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
this.dataGridView1.CellContentClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentClick);
this.dataGridView1.CellContentDoubleClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellContentDoubleClick);
data