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 : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Chage GDBG's cell color

Thread ID:

Created:

Updated:

Platform:

Replies:

6642 Aug 21,2003 03:31 AM UTC Aug 21,2003 04:57 AM UTC WinForms 1
loading
Tags: GridControl
Cradle
Asked On August 21, 2003 03:31 AM UTC

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 04:57 AM UTC

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.

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

;