Row Background Color

Hi,
I am using Grid Groupping Control.

Cells that are editable should have red background. cells that are not editable should have light backgound.

Pleas resolve the problem asap

Regards
Tannearu

6 Replies

AD Administrator Syncfusion Team December 1, 2006 09:13 AM UTC

Hi Tannearu,

You can handle the TableControlPrepareViewStyleInfo event and change the backcolor of the cell by checking the Style.ReadOnly property. Here is a code snippet to show this.

this.gridGroupingControl1.TableControlPrepareViewStyleInfo +=new GridTableControlPrepareViewStyleInfoEventHandler(gridGroupingControl1_TableControlPrepareViewStyleInfo);


private void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e)
{
if( e.Inner.Style.ReadOnly)
e.Inner.Style.BackColor = Color.Red;
else
e.Inner.Style.BackColor = Color.AliceBlue;
}

Best Regards,
Haneef


TH Tannearu Hazarathaiah Gupta December 1, 2006 09:34 AM UTC

Hi Haneef,
Thanks for you reply.

I need to change background color of the cell or a row depending on the particular condition.

For example i have 3 columns and 20 rows.


1) Empno
2) Empname
3) Salary

If Empname is 'Hazart' i want to appy background color of the cell/Row in red on some event or at the time of form load.

Please resolve the problem asap


Regards
Tannearu Hazarathaiah


TH Tannearu Hazarathaiah Gupta December 1, 2006 09:56 AM UTC

Hi Haneef,
Thanks for you reply.

Consider following example:

I have 3 columns.
1) EmpNo
2) EmpName
3) Salary

I am using GridGrouping control and records are grouped on "EmpName"

I am also using separate Filter control (custom control) with this grid. Using this control I can filter the existing grid records.
The feature I require is instead of filtering out the records, I want to highlight matching records.

Suppose, currently there are 20 records. Out of these records suppose 3 records have "EmpName" as "XYZ".
When I apply filter on EmpName = XYZ, I want these 3 records to be highlighted.


Thanks and Regards,
Tannearu Hazarathaiah




AD Administrator Syncfusion Team December 1, 2006 10:01 AM UTC

Hi Tannearu,

You can handle the TableControlPrepareViewStyleInfo event and conditionally changing the backcolor of the row. Here is a code snippet to show this.

private void gridGroupingControl1_TableControlPrepareViewStyleInfo(object sender, GridTableControlPrepareViewStyleInfoEventArgs e)
{
GridTableCellStyleInfo info = e.Inner.Style as GridTableCellStyleInfo;
Element el = info.TableCellIdentity.DisplayElement;
if( el != null && el.Kind == DisplayElementKind.Record)
{
GridRecordRow row = el as GridRecordRow;
if( row != null && row.ParentRecord != null)
{
object obj = row.ParentRecord.GetValue("EmpName");
if( obj != null && obj.ToString() == "Hazart")
{
e.Inner.Style.BackColor = Color.Red;
}
else
e.Inner.Style.BackColor = Color.AliceBlue;
}
}
}

Here is a sample.
GGCRowColor.zip

Best Regards,
Haneef


TH Tannearu Hazarathaiah Gupta December 1, 2006 10:05 AM UTC

Hi Haneef,
Thanks for you reply.

Consider following example:

I have 3 columns.
1) EmpNo
2) EmpName
3) Salary

I am using GridGrouping control and records are grouped on "EmpName"

I am also using separate Filter control (custom control) with this grid. Using this control I can filter the existing grid records.
The feature I require is instead of filtering out the records, I want to highlight matching records.

Suppose, currently there are 20 records. Out of these records suppose 3 records have "EmpName" as "XYZ".
When I apply filter on EmpName = XYZ, I want these 3 records to be highlighted.

Please resolve the problem asap


Thanks and Regards,
Tannearu Hazarathaiah



AD Administrator Syncfusion Team December 1, 2006 10:26 AM UTC

Hi Tannearu,

If you want to set style property for a row conditionally, then you can add a conditional format to the grid.TableDescriptor.ConditionaFormats collection. The CategoryView browser sample demonstrates the ConditionalFormat filters and the BaseStyles. The GridConditionalFormatDescriptor is a Descriptor that is used to format the rows that are based on the conditions or filters that are set for the column.

Here is a path.
\Syncfusion\Essential Studio\4.3.0.25\windows\Grid.Grouping.Windows\Samples\CategoryView\

Best Regards,
Haneef

Loader.
Up arrow icon