|
dev
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
datagridviewhi,
ive a datagridview cotrol on my winform.. i want to show a contextmenustrip when i right click a cell or row of my grid... how can i acheive it? One way you can do this is to handle the CellMouseUp event.
void dataGridView1_CellMouseUp(object sender, DataGridViewCellMouseEventArgs e) { if (e.Button == MouseButtons.Right) { DataGridView grid = sender as DataGridView; ContextMenuStrip menu = new ContextMenuStrip(); menu.Items.Add("Task1", null, new EventHandler(Task1_Click)); menu.Items.Add("Task2", null, new EventHandler(Task2_Click)); Point pt = grid.PointToClient(Control.MousePosition); menu.Show(dataGridView1, pt.X, pt.Y); } } ==================== Clay Burch Syncfusion, Inc. |
|||||||||||||||||||||||