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

Chage GDBG's cell color

Thread ID:





6642 Aug 21,2003 03:31 AM UTC Aug 21,2003 04:57 AM UTC WinForms 1
Tags: GridControl
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;


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