日期:2014-05-18 浏览次数:20924 次
private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e) {//选中单元格,弹出快捷菜单。 if (e.Button == MouseButtons.Right) { if (e.RowIndex >= 0) { this.dataGridView1.ClearSelection(); this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex].Selected = true; this.dataGridView1.CurrentCell = dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex]; //右击时选中 contextMenuStrip1.Show(MousePosition.X, MousePosition.Y); }