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

Want loop over Syncfusion.Windows.Forms.Grid.Grouping and set e.style.backcolor for specific row.

Hi i Want loop over Syncfusion.Windows.Forms.Grid.Grouping and set e.style.backcolor for specific row.

so i want some ////code like

for(int i=;;;)
{
e.style.backcolor ="red";
}

Hi my requirement is change specific row back color at specific time(assume on timer), so how i can do it.????

3 Replies

RA Rajagopal Syncfusion Team April 25, 2007 09:19 PM UTC

Hi Ashok,

You can try the code like this in the QueryCellStyleInfo event of the GridGroupingControl, to color any specific record(row) in grid.

void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if(e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record)
{
Element el = e.TableCellIdentity.DisplayElement;
Record rec = el.ParentRecord;
int recordIndex = this.gridGroupingControl1.Table.Records.IndexOf( rec );
if( recordIndex == 3 )
e.Style.BackColor = Color.Pink;
}
}

Let us know if you have any further queries.
Thanks for using Syncfusion Products.

Regards,
Rajagopal



AS Ashok April 26, 2007 01:51 PM UTC

Hi But i want this event on my click based, where i can loop all rows and get specific row, because this event only fired when Syncfusion.Windows.Forms.Grid.Grouping acitve
.
on click event i am not able to grap
"e.TableCellIdentity.DisplayElement"


>Hi Ashok,

You can try the code like this in the QueryCellStyleInfo event of the GridGroupingControl, to color any specific record(row) in grid.

void gridGroupingControl1_QueryCellStyleInfo(object sender, GridTableCellStyleInfoEventArgs e)
{
if(e.TableCellIdentity.DisplayElement.Kind == DisplayElementKind.Record)
{
Element el = e.TableCellIdentity.DisplayElement;
Record rec = el.ParentRecord;
int recordIndex = this.gridGroupingControl1.Table.Records.IndexOf( rec );
if( recordIndex == 3 )
e.Style.BackColor = Color.Pink;
}
}

Let us know if you have any further queries.
Thanks for using Syncfusion Products.

Regards,
Rajagopal




AD Administrator Syncfusion Team April 26, 2007 04:39 PM UTC

In your click event, set a flag (or create a collection of row indexes) to indicate that you want to color certain rows. Then inside the QueryCellStyleInfo, check this flag (or check if the rowIndex is in your collection), and if so, then set the BackColor as shown above.

The reason you need to do it this way is that the GridGroupingControl does not store properties for each row. It does this for efficiency (so you can have many, many rows). So, you cannot just set such properties on a row. To affect a visual property on a row or individual cell, you need to do it on demand in a an event (like QueryCellStyleInfo).

Now if you really want to store something on a row by row basis (so you can set it and not have to provide it in an event), then you can create a custom engine which will allow you to create your own row objects which will allow you to add properties such as a row color that you could set. The ResizableRows sample that we ship does this to add a RowHeight property to each row. You could similarly add a Color property, but generally it is simpler to set such properties dynamically in an event like QueryCellStyleInfo.


Loader.
Live Chat Icon For mobile
Up arrow icon