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.

Access cell colors inside CurrentCellChanging handler?

Thread ID:





6400 Aug 11,2003 06:46 PM Aug 12,2003 12:59 AM Windows Forms 1
Tags: GridControl
Administrator [Syncfusion]
Asked On August 11, 2003 06:46 PM

I have a grid with a lot of repetitive cell values which clutter up the display. It's easy enough to handle PrepareViewStyleInfo and set the TextColor equal to the BackColor. But the user needs to be able to edit the values, so I'm trying to force the TextColor back to Black inside a CurrentCellChanging handler. Problem is, I have no idea how to get at the cell colors from there. Usually, they're only accessible, I think, from methods that supply a GridStyleInfo object.

Administrator [Syncfusion]
Replied On August 12, 2003 12:59 AM

One comment is that if you 'set' the color in PrepareViewStyleInfo, this will step on any other setting you may do (unless it is done later than PrepareViewStyleInfo). So, I would suggest you set both the non-editing color and editing color in PrepareViewStyleInfo.
private void gridControl1_PrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.GridPrepareViewStyleInfoEventArgs e)
	if(e.RowIndex > 0 && e.ColIndex > 0)
		GridCurrentCell cc = this.gridControl1.CurrentCell;
		if(cc != null && cc.HasCurrentCellAt(e.RowIndex, e.ColIndex) && cc.IsEditing)
			e.Style.TextColor = Color.Black;
		        e.Style.TextColor = Color.Gray;
If you want the color in CurrentCellChanging, then you would normally use an indexer on the grid to get the style for the cell. You would use grid.CurrentCell.RowIndex and grid.CurrentCell.ColIndex to specifiy the indexes.


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.