首页
学习
活动
专区
圈层
工具
发布

甘特图
EN

Stack Overflow用户
提问于 2009-06-24 09:29:02
回答 2查看 1.2K关注 0票数 0

有没有人在LinQ3.5中使用了plexityhide的GTP.NET,因为我尝试根据从asp.net查询中获得的变量给各个单元格着色,如下所示

代码语言:javascript
复制
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语句中的语法是他们推荐的语法。有谁能帮上忙吗?

非常感谢

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2009-08-04 09:19:41

确保设置了CellLayout.BackgroundUse=true。如果不这样做,背景颜色将被忽略。

由于您使用ASP.NET,cellLayouts将生成一个css,因此您必须将新克隆的CellLayouts添加到CellLayouts上的集合中:

Gantt_ASP.Gantt.Grid.CellLayouts.Add(cl);

票数 1
EN

Stack Overflow用户

发布于 2015-12-09 14:49:37

代码语言:javascript
复制
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

它工作正常...:)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/1037326

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档