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

When looping thru ggc.Table.Records, how can I tell that a records meets my Conditional Format Descriptor

I have a ggc in which I have define a GridConditional format to to disabledenable the row based on a certain conditions like...

...Appearance.AnyRecordCell.Enabled = false;


when manually looping thru the record of the gggc that I obtained by ggc.Table.Records, how can I tell if the UI row that this record is bounded to is disabled or enabled, in other words, meets the condition of the Conditional format.

1 Reply

JS Jeba S Syncfusion Team August 20, 2007 06:53 AM UTC

Hi James,

Thank you for your details.

The grid has no collection of records that satisfy a particular conditional format. The formatting for conditional formatting is determined

on demand as the record is drawn in the grid.

So, if you want a collection of such records, then you would have to loop through all the current records in the grid and check the

GridTableViewStyle to see if that particular record has the style applied to it.

Please refer the steps that show how this can be done.

1) This code sets up the formatting and additionally, puts a 1 in the Tag field of the row header cell.

GridConditionalFormatDescriptor gcfd = new GridConditionalFormatDescriptor();
gcfd.Expression = "[Col1] > [Col2]";
gcfd.Appearance.AnyRecordFieldCell.Enabled = false;
gcfd.Appearance.AnyCell.BackColor = Color.Red;
gcfd.Appearance.RowHeaderCell.Tag = 1; //mark the header cell
this.gridGroupingControl1.TableDescriptor.ConditionalFormats.Add(gcfd);


2) Here is a button handler that loops through all records in the grid to test whether this "1" value is set in the header cell. It simply

points a particular field value in a listbox, but you could create an List or ArrayList of records that satisfy the filter.

private void button1_Click(object sender, EventArgs e)
{
foreach (GridRecord rec in gridGroupingControl1.Table.FilteredRecords)
{
int rowIndex = gridGroupingControl1.Table.DisplayElements.IndexOf(rec);
GridTableCellStyleInfo style = gridGroupingControl1.TableControl.GetTableViewStyleInfo(rowIndex, 0); //0 is row header
if (style.Tag != null && style.Tag.Equals(1))
{
listBox1.Items.Add(rec.GetValue("Col0"));
}
}
}

Please refer the sample which implements the above said feature:
http://websamples.syncfusion.com/samples/Grid.Windows/F67447/main.htm

Kindly let us know if you need any further assistance.

Thank you for using Syncfusion Products.

Best Regards,
Jeba.

Loader.
Live Chat Icon For mobile
Up arrow icon