有没有人使用plexityhide的GTP.NET for asp.net 3.5作为我试图根据我从linq查询得到的var为各个单元格着色如下
PilotDataContext pilot = new PilotDataContext();
var schedule = from x in pilot.slot_tbl_Schedules select x;
foreach (var s in schedule)
{
if (s.AppointmentType == "Repair")
{
CellLayout cl = gn.GetCell(0).Layout.Clone() as CellLayout;
gn.GetCell(0).Layout = cll;
cl.BackgroundColor = Color.Red;
cl.SelectedColor = Color.Red;
}
else if (s.AppointmentType == "Service")
{
CellLayout cl = gn.GetCell(0).Layout.Clone() as CellLayout;
gn.GetCell(0).Layout = cl;
cl.BackgroundColor = Color.Blue;
}
else if (s.AppointmentType == "TravelTime")
{
CellLayout cl = gn.GetCell(0).Layout.Clone() as CellLayout;
gn.GetCell(0).Layout = cl;
cl.BackgroundColor = Color.Green;
}
else if (s.AppointmentType == "AnnualLeave")
{
CellLayout cl = gn.GetCell(0).Layout.Clone() as CellLayout;
gn.GetCell(0).Layout = cl;
cl.BackgroundColor = Color.Yellow;
}
}
if语句中的语法是他们推荐的,任何人都可以帮助解决这个问题
非常感谢
答案 0 :(得分:1)
确保设置CellLayout.BackgroundUse = true。如果不这样,则忽略背景颜色。
由于您使用ASP.NET,cellLayouts将生成一个css,因此您必须将新克隆的CellLayouts添加到CellLayouts上的集合中:
Gantt_ASP.Gantt.Grid.CellLayouts.Add(CL);
答案 1 :(得分:0)
Dim cl2 As CellLayout = TryCast(e.GridNode.GetCell(4).Layout.Clone(), CellLayout)
cl2.SelectedColor = Color.Red
cl2.FontColor = Color.Red
cl2.BackgroundColor = Color.Blue
cl2.BackgroundUse = True ' when is true background color change
e.GridNode.GetCell(4).Layout = cl2
它工作正常..... :)。