>I already tried. The default context menu pops up.Ooops, my bad. I have a test application where I test all kinds of stuff. I saw somewhere in that app where I was setting the Grid's ContextMenu, as I mentioned. I assumed that was what was making it work. After a bit more digging, I see I was wrong. You need to handle the Grid's CellMouseDown event like so:
private void dataGridView1_CellMouseDown(object sender, DataGridViewCellMouseEventArgs e)
{
if (e.Button == MouseButtons.Right)
{
this.dataGridView1.CurrentCell = this.dataGridView1.Rows[e.RowIndex].Cells[e.ColumnIndex];
this.oContextMenu.Show(this.dataGridView1, new Point(e.RowIndex, e.ColumnIndex));
}
}
That should do the trick. Sorry about that!!!
~~Bonnie
>>
>I retract that... The user will be right-clicking and pasting into a DataGridView cell in a WinForms app. Right now, the standard, default
>>>context menu pops up. I don't see any way to trap it.>>
>>If you want a custom ContextMenu, all you have to do is set the Grid's ContextMenu like this:
>>
>>MyGrid.ContextMenu = this.MyCustomContextMenu;
>>
>>Does that help at all?
>>
>>~~Bonnie
>
>I already tried. The default context menu pops up.