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

How to prevent "Header" cell selecting

Hi, I''m using a grid that combines "Header" and "Static" rows (Refer to the attached demo app). When the the user is selecting a range of cells, how can I prevent the selection of the header rows? It should look like Srceenshot1, but unfortunately it looks like Srceenshot2. Thanks in advance, Holger Persch GridTest_564.zip

3 Replies

AD Administrator Syncfusion Team November 2, 2004 09:50 AM UTC

Try this code to see if it gives you what you want.
private void gridControl_SelectionChanged(object sender, GridSelectionChangedEventArgs e)
{
	if(e.Range.IsCells)
	{
		for(int row = e.Range.Top; row <= e.Range.Bottom; ++row)
		{
			if(this.gridControl[row,1].CellType == "Header")
				this.gridControl.Selections.SelectRange(GridRangeInfo.Row(row), false);
		}
	}
}


AD Administrator Syncfusion Team November 2, 2004 09:55 AM UTC

Another solution is to derive the grid and override this virtual method, only inverting teh cells that you want.
protected virtual void DrawInvertCell(Graphics g, int rowIndex, int colIndex, Rectangle rectItem, bool inPaint)
{
          // Note: rectItem only is the visible bounds of cell
      if (!CurrentCell.HasCurrentCellAt(rowIndex, colIndex))
             m_gridPaint.DrawInvertCell(g, rowIndex, colIndex, rectItem, inPaint); 
             m_bInvertRect = false;
}


HP Holger Persch November 3, 2004 04:17 AM UTC

As always, a perfect answer! Regards, Holger Persch

Loader.
Live Chat Icon For mobile
Up arrow icon