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

Change a Cell and repaint with other background color

Thread ID:





22014 Dec 1,2004 02:30 PM UTC Dec 1,2004 04:07 PM UTC WinForms 3
Tags: GridControl
Liliana Faerman
Asked On December 1, 2004 02:30 PM UTC

Hello How can repaint a cell with other background color in this cell, in the method CurrentCellAcceptedChanges? Thank of your risponse Liliana

Liliana Faerman
Replied On December 1, 2004 02:38 PM UTC

Sorry, i forgot, in DBDG

Administrator [Syncfusion]
Replied On December 1, 2004 03:13 PM UTC

In a GridDataBoundGrid, in order to set cell specific backcolors, then you must handle the PrepareViewStyleInfo event and dynamically provide the color based on the e.RowIndex and e.ColIndex values passed in, and you have to keep providing this backcolor as long as you want to see it. See this KB. Here are two eventhandlers that I think does what you described for a single cell.
private int colorRow = -2;
private int colorCol = -2;
private void gridDataBoundGrid1_CurrentCellAcceptedChanges(object sender, CancelEventArgs e)
	int tempRow = this.colorRow;
	int tempCol = this.colorCol;
	this.colorRow = -2;
	this.colorRow = -2;
	if(tempRow > -2)
		//repaint the old one so color goes away
		this.gridDataBoundGrid1.RefreshRange(GridRangeInfo.Cell(tempRow, tempCol));
	GridCurrentCell cc = this.gridDataBoundGrid1.CurrentCell;
	this.colorCol = cc.ColIndex;
	this.colorRow = cc.RowIndex;
	//paint the new one
	this.gridDataBoundGrid1.RefreshRange(GridRangeInfo.Cell(this.colorRow, this.colorCol));
private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
	if(e.ColIndex == this.colorCol && e.RowIndex == this.colorRow)
		e.Style.BackColor = Color.Red;

Liliana Faerman
Replied On December 1, 2004 04:07 PM UTC

Thanks Clay. Regards!!


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