Question
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();
gn.GetCell(0).Content.Value=”first_name”;
.
.
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
gantt1.Grid.GridStructure.RootNodes[0].GetCell(0).Layout.CellLayouts[0].Font
Color=Color.Red; – every employee is red
gantt1.Grid.GridStructure.RootNodes[0].Nodes.Columns[0].ColumnCell.Layout.Fo
ntColor=Color.Red; – every employee is red
gantt1.Grid.GridStructure.RootNodes[0].Nodes.Columns[0].ColumnCell.Layout=ga
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
Answer
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;
GetCell(0).Layout=cl;
cl.Font.Color=Color.Red;
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”);