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

How to set cells background color

Hi,

I am using syncfusion GridDataBoundGrid. I want set back colors following criteria.


(Cells that are editable shoule have a white background and celss that are not editable should have light grey back round.)

Please resolve the problem ASAP.


Reagrds
Tannearu Hazarathaiah

6 Replies

AD Administrator Syncfusion Team November 23, 2006 08:52 AM UTC

Hi Tannearu,

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 the cell you want to change, you set e.Style.BackColor/Style.Readonly to the value you want.

Please refer to the following KBs for more details.
How do I change the Backcolor of a single cell in a GridDataBoundGrid
How do I make the Cells Read-only in GridDataBoundGrid?


Best Regards,
Haneef


TH Tannearu Hazarathaiah Gupta November 23, 2006 09:48 AM UTC

Hi Haneef,
Thanks for your Reply. I Need Particular Solution following criteria.

I check the progrmatically about cell behaviour and Change his backround Color. I don't want set Design time values.

I nedd check at runtime about the cell type is read only and Set Background Color. Please help me. This urgent.


Thanks
Tannnearu Hazartahaiah




>Hi Tannearu,

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 the cell you want to change, you set e.Style.BackColor/Style.Readonly to the value you want.

Please refer to the following KBs for more details.
How do I change the Backcolor of a single cell in a GridDataBoundGrid
How do I make the Cells Read-only in GridDataBoundGrid?


Best Regards,
Haneef


TH Tannearu Hazarathaiah Gupta November 23, 2006 10:01 AM UTC

Hi Haneef,
Thanks for your reply. But i Need to find out each cells Behaviour and set color at the load of the grid it self. is ther any code sniffet is avilabe give me reply asap.


Cheers
Tannearu Hazartahaiah

>Hi Haneef,
Thanks for your Reply. I Need Particular Solution following criteria.

I check the progrmatically about cell behaviour and Change his backround Color. I don't want set Design time values.

I nedd check at runtime about the cell type is read only and Set Background Color. Please help me. This urgent.


Thanks
Tannnearu Hazartahaiah




>Hi Tannearu,

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 the cell you want to change, you set e.Style.BackColor/Style.Readonly to the value you want.

Please refer to the following KBs for more details.
How do I change the Backcolor of a single cell in a GridDataBoundGrid
How do I make the Cells Read-only in GridDataBoundGrid?


Best Regards,
Haneef


TH Tannearu Hazarathaiah Gupta November 23, 2006 10:22 AM UTC

Hi Haneef,
Thanks For your reply. But I Need set the Background color in the runtime Means i Have to check the cells Status means Editable or NotEditable. How to check it out its editable or Not Editable at runtime. Please resolve the problem.

Regards
Tannearu

>Hi Haneef,
Thanks for your reply. But i Need to find out each cells Behaviour and set color at the load of the grid it self. is ther any code sniffet is avilabe give me reply asap.


Cheers
Tannearu Hazartahaiah

>Hi Haneef,
Thanks for your Reply. I Need Particular Solution following criteria.

I check the progrmatically about cell behaviour and Change his backround Color. I don't want set Design time values.

I nedd check at runtime about the cell type is read only and Set Background Color. Please help me. This urgent.


Thanks
Tannnearu Hazartahaiah




>Hi Tannearu,

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 the cell you want to change, you set e.Style.BackColor/Style.Readonly to the value you want.

Please refer to the following KBs for more details.
How do I change the Backcolor of a single cell in a GridDataBoundGrid
How do I make the Cells Read-only in GridDataBoundGrid?


Best Regards,
Haneef


AD Administrator Syncfusion Team November 23, 2006 10:35 AM UTC

Hi Tannearu,

Use the Readonly property to find the editiable cell in a grid. Here is a code snippet to show this.

private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if( e.Style.ReadOnly )
e.Style.BackColor = Color.Gray;
else
e.Style.BackColor = Color.AliceBlue ;
}

Please refer to the attached sample for implementation.
GDBGReadonlyCellType.zip

Best Regards,
Haneef


TH Tannearu Hazarathaiah Gupta November 23, 2006 10:58 AM UTC

Hi Haneef,

Thanks. Its working.

Regards
Tannearu Hazarathaiah




>Hi Tannearu,

Use the Readonly property to find the editiable cell in a grid. Here is a code snippet to show this.

private void gridDataBoundGrid1_PrepareViewStyleInfo(object sender, GridPrepareViewStyleInfoEventArgs e)
{
if( e.Style.ReadOnly )
e.Style.BackColor = Color.Gray;
else
e.Style.BackColor = Color.AliceBlue ;
}

Please refer to the attached sample for implementation.
GDBGReadonlyCellType.zip

Best Regards,
Haneef

Loader.
Live Chat Icon For mobile
Up arrow icon