10442 : Changing single Cells font color based on a rule


I have a procedure that fills timeItems in the dateScaler (from dataset)…

private void fillGridItems…
for (int i=0; i<dsEmployees.Tables[“person”].Rows.Count; ++i)

GridNode gn=gantt1.Grid.GridStructure.RootNodes.AddNode();

GanttRow gr = GanttRow.FromGridNode(gn);

TimeItem ti1=gr.Layers[0].AddNewTimeItem();


After filling all items, user can click on date scaler and insert new time items. (add new rows in the same dataset) My question is…i’m counting how many time items every employee has for every day. If that number > 9, I would like FontColor in the grid for that employee to be Color.Red.

I was trying something like this

Color=Color.Red; – every employee is red

ntColor=Color.Red; – every employee is red

ntt1.Grid.CellLayouts.GetFromName(“layout”); – makes no change

when I fill items from the database I can reference the column with
gn.GetCell(0) and then the value for that cell.
Why I can not call only one column…

i want to avoid calling the same procedure (fillGridItems) and making cell.layout and then adding to cell.layouts … if it is possible only change the color of the text in the grid


The CellLayout is used by multiple cells.

One way to reach your desired result is to create a new CellLayout for each cell like this
                        CellLayout cl=GetCell(0).Layout.Clone() as CellLayout;

Or why not add your needed celllayouts in design time to the Gantt.CellLayouts collection and then in runtime assign the correct one like this

                        GetCell(0).Layout = Gantt.CellLayouts.GetFromName(“OverWorked”);


Leave a Reply