We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Obtaining column header from right mouse click

We are trying to obtain the column header cell from a right mouse click to popup a context menu. Unfortunately the Current Cell property does not reflect the selected header.


2 Replies

HA haneefm Syncfusion Team April 4, 2007 03:43 PM UTC

Hi Thomas,

Here is code that catches a mousedown event and tests to see if it is a right-click on a header.

private void gridDataBoundGrid1_MouseDown(object sender, System.Windows.Forms.MouseEventArgs e)
{
if(e.Button == MouseButtons.Right)
{
Point clickPoint = gridDataBoundGrid1.PointToClient(Cursor.Position);
int rowIndex, colIndex;
gridDataBoundGrid1.PointToRowCol(clickPoint, out rowIndex, out colIndex);
if(rowIndex == 0 && colIndex > 0)
MessageBox.Show("gridDataBoundGrid1_MouseDown");
}
}

Best regards,
Haneef


TP Thomas Pang April 4, 2007 06:04 PM UTC

Thank you for this.

Loader.
Live Chat Icon For mobile
Up arrow icon