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

GGCproblem Urgent

hi Iam using GGC.Iwant to change the backcolor of some records of the grid .ie,based on a condition.But for a grid without any child tables it is working.But ifthe grid have some childtables & some of the grid have filterbars.,some have addnewrecords,.. this is not working correctly.I want to create a generic function to check this for the parent & child ones.ie if my condition is true,I want that record to be gray in color. Now iam using this code private void grid1_TableControlPrepareViewStyleInfo(object sender, Syncfusion.Windows.Forms.Grid.Grouping.GridTableControlPrepareViewStyleInfoEventArgs e) { if(e.Inner.RowIndex > 2 && e.Inner.ColIndex > 0) { if(this.gridUOMTye.TableModel.Model[e.Inner.RowIndex,3].CellType=="CheckBox") { object o = this.gridUOMTye.TableModel.Model[e.Inner.RowIndex,3].CellValue; if(o!=null) { bool val = o.ToString() == true.ToString(); if(val) { e.Inner.Style.CellType="Static"; e.Inner.Style.BackColor = Color.LightGray; } } } } Can anybody solve this problem?

4 Replies

AD Administrator Syncfusion Team March 22, 2006 07:16 AM UTC

Hi, The GridConditionalFormatDescriptor can be used to format a row conditionally, without handling any events. Please refer to the attached sample and let us know if this servers your need. Regards, Calvin.

42181.zip


AD Administrator Syncfusion Team March 22, 2006 07:33 AM UTC

Hi, In the previous sample please add the fd.Appearance.RecordPlusMinusCell.CellType = "PushButton"; after setting fd.Appearance.AnyRecordFieldCell.CellType = "Static"; which will avoid the RecordPlusMinusCell cell from changing into Static cell type. Bellow is a code snippet. GridTableDescriptor gtd = this.gridGroupingControl1.GetTableDescriptor("ParentTable"); GridConditionalFormatDescriptor fd = new GridConditionalFormatDescriptor("ColorMe"); fd.Expression = "[parentID] = 1"; fd.Appearance.AnyRecordFieldCell.CellType = "Static"; fd.Appearance.RecordPlusMinusCell.CellType = "PushButton"; fd.Appearance.AnyRecordFieldCell.BackColor = Color.LightGray; gtd.ConditionalFormats.Add(fd); gtd = this.gridGroupingControl1.GetTableDescriptor("ChildTable"); fd = new GridConditionalFormatDescriptor("ColorMe"); fd.Expression = "[childID] = 1"; fd.Appearance.AnyRecordFieldCell.CellType = "Static"; fd.Appearance.RecordPlusMinusCell.CellType = "PushButton"; fd.Appearance.AnyRecordFieldCell.BackColor = Color.LightGray; gtd.ConditionalFormats.Add(fd); gtd = this.gridGroupingControl1.GetTableDescriptor("GrandChildTable"); fd = new GridConditionalFormatDescriptor("ColorMe"); fd.Expression = "[GrandChildID] LIKE ''1*''"; fd.Appearance.AnyRecordFieldCell.CellType = "Static"; fd.Appearance.RecordPlusMinusCell.CellType = "PushButton"; fd.Appearance.AnyRecordFieldCell.BackColor = Color.LightGray; gtd.ConditionalFormats.Add(fd); Regards, Calvin.


RE resmi March 23, 2006 03:30 AM UTC

Sorry .This will not work for my case.In my problem the condition which iam saying is not a field or column of the grid.Based on some other condition ,I''ve to change the back ground . Can you give a solution


AD Administrator Syncfusion Team March 23, 2006 12:28 PM UTC

Hi, I am not sure about the condition that you are checking to set a back color of a row. To use the TableModel for a nested table in a GridGroupingControl this.gridGroupingControl1.GetTableModel(tableName)[e.Inner.RowIndex, e.Inner.RowIndex]must be used. But to set the styles for rows dynamically the QueryCellStyleInfo event would be the best. Please refer to the attached sample. Regards, Calvin.

421810.zip

Loader.
Live Chat Icon For mobile
Up arrow icon