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.
Unfortunately, activation email could not send to your email. Please try again.

How to get column index on click of column header

Thread ID:

Created:

Updated:

Platform:

Replies:

58289 Mar 21,2007 01:24 PM Mar 21,2007 01:52 PM Windows Forms 1
loading
Tags: GridControl
Administrator [Syncfusion]
Asked On March 21, 2007 01:24 PM

Hi,

Which event will give me the column index of the column when mouse button is clicked on column header.

Thanks

Administrator [Syncfusion]
Replied On March 21, 2007 01:52 PM

Hi,

You can handle the MouseDown event of the grid and call the PointToRowCol method to detect the RowIndex and ColIndex of the cell in a Grid. Here is a code snipet

void gridDataBoundGrid1_MouseDown(object sender, MouseEventArgs e)
{
int row, col;
GridDataBoundGrid grid = sender as GridDataBoundGrid;
if (grid.PointToRowCol(new Point(e.X,e.Y), out row, out col))
{
if (grid.Model[row,col].CellType == "ColumnHeaderCell")
{
MessageBox.Show(string.Format( "Column Header Index is {0}", col));
}
}
}

Best regards,
Haneef

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.

;