其他分享
首页 > 其他分享> > DataGridView右键单击弹出菜单并选中行

DataGridView右键单击弹出菜单并选中行

作者:互联网

private void dataGridView_OLUsers_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e) { if (e.Button == MouseButtons.Right) { if (e.RowIndex >= 0) { dataGridView_OLUsers.ClearSelection(); dataGridView_OLUsers.Rows[e.RowIndex].Selected = true; dataGridView_OLUsers.CurrentCell = dataGridView_OLUsers.Rows[e.RowIndex].Cells[e.ColumnIndex]; contextMenuStrip1.Show(MousePosition.X, MousePosition.Y); } } }

标签:Rows,OLUsers,MousePosition,单击,RowIndex,dataGridView,右键,DataGridView
来源: https://www.cnblogs.com/renzhe-org/p/15546437.html