登 录
1.添加一个menustrip到form.
添加相应的子菜单。
定义一全局Point 值,以便确定右键菜单的位置。
2.在datagridview的cell_mousedown事件中写代码:
private void QuerydataGV_CellMouseClick(object sender, DataGridViewCellMouseEventArgs e) { if (e.Button == MouseButtons.Right) { if (this.QuerydataGV.Columns[e.ColumnIndex].Name.Equals("workbill")) { cmMenu.Show(this.QuerydataGV, newP); // MessageBox.Show(this.QuerydataGV.Rows[e.RowIndex].Cells[e.ColumnIndex].Value.ToString()); } } }
3.在datagridview的mousedown事件中写代码:
private void dataGridView1_MouseDown(object sender, MouseEventArgs e) { newP = new Point(e.X, e.Y); }
这样就搞定了。
抱歉!评论已关闭.