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
close icon

Contextmenu on Header Row

Hi I am having a context menu for my Databounddatagrid, I am enabling contextMenu when user clicks on cells which are not static and readonly. I am doing this in grid_MouseDown event like this if(e.Button == MouseButtons.Right) { if(this.Grid.CurrentCell.ColIndex != 1 && this.Grid.CurrentCell.ColIndex != 2) { Grid.ContextMenu=null; } else { Grid.ContextMenu=this.cmnuContextMnu; } } here Columns ColIndex 1 & 2 cells are non static. the above code works fine when i am clicking on static and nonstatic cells but when i click on Columns Headers cells the ContextMenu still popsup, how do i get the RowIndex in mousedown event. to get the row index(RowIndex = 0 for header row cells), i used cellclick event in which i had placed the above MouseDown event code..but still iam having the problems is there any way i can effectively show the contextmenu only on non static cells. how do desable context menu for header row cells. ---seash

1 Reply

AD Administrator Syncfusion Team August 18, 2004 07:21 AM UTC

You can get the row/column with code like this:
int row, col;
Point pt = new Point(e.X, e.Y);
if(grid.PointToRowCol(pt, out row, out col, -1))
{
    // row and col should point to the cell
}

Loader.
Live Chat Icon For mobile
Up arrow icon