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.

Chage GDBG's cell color

Thread ID:

Created:

Updated:

Platform:

Replies:

6642 Aug 20,2003 11:31 PM Aug 21,2003 12:57 AM Windows Forms 1
loading
Tags: GridControl
Cradle
Asked On August 20, 2003 11:31 PM

i try this code: this.gridDataBoundGrid[8,10].BackColor=Color.Red; but can not change cell color. Why????????

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

In a GridDataBoundGrid, you cannot set cell specific properties (other than CellValue or Text) using an indexer as in your sample code. The reason is that in a GridDataBoundGrid, the only data storage is the bound datasource. That only holds a single value. It does not hold TextColor, or BackColor , or any of the other many cell specific properties. So, in order to set cell specific properties in a GriDDataBoundGrid, you must catch the PrepareViewStyleInfo event (or Model.QueryCellInfo event). In your handler, you check e.RowIndex and e.ColIndex, and if these point to some cell you want to change, you set e.Style to the value you want.
private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
	if(e.ColIndex == 2 && e.RowIndex == 2)
	{
		e.Style.BackColor = Color.Red;
	}
}

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.

;