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. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

How to prevent "Header" cell selecting

Thread ID:





21081 Nov 2,2004 09:05 AM UTC Nov 3,2004 04:17 AM UTC WinForms 3
Tags: GridControl
Holger Persch
Asked On November 2, 2004 09:05 AM UTC

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

Administrator [Syncfusion]
Replied On 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)
		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);

Administrator [Syncfusion]
Replied On 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;

Holger Persch
Replied On November 3, 2004 04:17 AM UTC

As always, a perfect answer! Regards, Holger Persch


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.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon 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.Close Icon

Live Chat Icon For mobile
Live Chat Icon