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.

Row Background Color

Thread ID:

Created:

Updated:

Platform:

Replies:

52631 Dec 1,2006 02:10 AM Dec 1,2006 05:26 AM Windows Forms 6
loading
Tags: GridControl
Tannearu Hazarathaiah Gupta
Asked On December 1, 2006 02:10 AM

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

Administrator [Syncfusion]
Replied On December 1, 2006 04:13 AM

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

Tannearu Hazarathaiah Gupta
Replied On December 1, 2006 04:34 AM

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

Tannearu Hazarathaiah Gupta
Replied On December 1, 2006 04:56 AM

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



Administrator [Syncfusion]
Replied On December 1, 2006 05:01 AM

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

Tannearu Hazarathaiah Gupta
Replied On December 1, 2006 05:05 AM

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


Administrator [Syncfusion]
Replied On December 1, 2006 05:26 AM

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

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.

;