This works for me...
private void MyDataGridView_MouseUp(object sender, MouseEventArgs e)
{
if (e.Button != MouseButtons.Right) return;
DataGridView.HitTestInfo Hti = MyDataGridView.HitTest(e.X, e.Y);
if (Hti.Type == DataGridViewHitTestType.Cell)
{
if (MyDataGridView.Rows.Count 0)
{
MyDataGridView.CurrentCell = MyDataGridView[Hti.ColumnIndex,
Hti.RowIndex];
ShowContextMenu(this.PointToScreen(MyDataGridView. PointToClient(e.Location))
);
}//EndIf
}//EndIf
}//EndEvh MyDataGridView_MouseUp
Hope this helps,
Steph.
"DBC User" <db*****@gmail.comwrote in message
news:11**********************@48g2000cwx.googlegro ups.com...
Hi All,
I have a data grid and I created a context menu for the data grid and
is working fine. The context menu is sensitive to the current selected
row.
I would like to know., when a user RIGHT click on a particular row, I
want to select the row and then show the context menu (like outlook).
Could someone give me some pointers on this. I did some experiments but
none worked so far.
Thanks.