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 prevent "Header" cell selecting

Thread ID:

Created:

Updated:

Platform:

Replies:

21081 Nov 2,2004 04:05 AM Nov 2,2004 11:17 PM Windows Forms 3
loading
Tags: GridControl
Holger Persch
Asked On November 2, 2004 04:05 AM

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 04:50 AM

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);
		}
	}
}

Administrator [Syncfusion]
Replied On November 2, 2004 04:55 AM

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 2, 2004 11:17 PM

As always, a perfect answer! Regards, Holger Persch

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.

;