1、列宽的问题? 生成甘特的表的自定义函数BuildGanttTable中,加粗的一行的作用是什么:
Dim tbl As Table = Tables("任务")
Tables("窗口1_Table2").StopRedraw()
Dim StartDate As Date = tbl.Compute("Min(开始日期)", "开始日期 IS NOT NULL")
Dim EndDate As Date = tbl.Compute("Max(结束日期)","结束日期 IS NOT NULL")
Dim dt = StartDate
Dim Builder As New DataTableBuilder("统计")
Do
Dim nm As String = dt.Year & "年" & dt.Month & "月_" & dt.Day
Builder.Adddef(nm,Gettype(String),1)
dt = dt.Adddays(1)
If dt > Enddate Then
Exit Do
End If
Loop
Tables("窗口1_Table2").DataSource = Builder.buildDataSource
For Each cl As Col In Tables("窗口1_Table2").Cols
Dim cd As Date = cl.Name.Replace("年","-").Replace("月_","-")
Dim d1 As Date = new Date(cd.year,5,1)
Dim d2 As Date = new Date(cd.year,10,1)
If cd.DayOfWeek = 0
Tables("窗口1_Table2").SetHeaderCellForeColor(cl.name,Color.Red,1)
ElseIf cd.DayOfWeek = 6
Tables("窗口1_Table2").SetHeaderCellForeColor(cl.name,Color.green,1)
ElseIf cd >=d1 AndAlso cd <= d1.AddDays(2)
Tables("窗口1_Table2").SetHeaderCellForeColor(cl.name,Color.Yellow,1)
ElseIf cd >=d2 AndAlso cd <= d2.AddDays(6)
Tables("窗口1_Table2").SetHeaderCellForeColor(cl.name,Color.Yellow,1)
End If
cl.width = 20
Next
Functions.Execute("AddGanttRows")
Tables("窗口1_Table2").ResumeRedraw()
2、设置字体,再加一行即可:
Dim tbl As Table = Tables("任务")
Tables("窗口1_Table2").StopRedraw()
Dim StartDate As Date = tbl.Compute("Min(开始日期)", "开始日期 IS NOT NULL")
Dim EndDate As Date = tbl.Compute("Max(结束日期)","结束日期 IS NOT NULL")
Dim dt = StartDate
Dim Builder As New DataTableBuilder("统计")
Tables("窗口1_Table2").Font = New Font("宋体",12,FontStyle.Underline)
Do
Dim nm As String = dt.Year & "年" & dt.Month & "月_" & dt.Day
Builder.Adddef(nm,Gettype(String),1)
dt = dt.Adddays(1)
If dt > Enddate Then
Exit Do
End If
Loop
Tables("窗口1_Table2").DataSource = Builder.buildDataSource
For Each cl As Col In Tables("窗口1_Table2").Cols
Dim cd As Date = cl.Name.Replace("年","-").Replace("月_","-")
Dim d1 As Date = new Date(cd.year,5,1)
Dim d2 As Date = new Date(cd.year,10,1)
If cd.DayOfWeek = 0
Tables("窗口1_Table2").SetHeaderCellForeColor(cl.name,Color.Red,1)
ElseIf cd.DayOfWeek = 6
Tables("窗口1_Table2").SetHeaderCellForeColor(cl.name,Color.green,1)
ElseIf cd >=d1 AndAlso cd <= d1.AddDays(2)
Tables("窗口1_Table2").SetHeaderCellForeColor(cl.name,Color.Yellow,1)
ElseIf cd >=d2 AndAlso cd <= d2.AddDays(6)
Tables("窗口1_Table2").SetHeaderCellForeColor(cl.name,Color.Yellow,1)
End If
cl.width = 25
Next
Functions.Execute("AddGanttRows")
Tables("窗口1_Table2").ResumeRedraw()