试试
If DrawGannt Then
Dim r As Row = Tables("任务").Rows(e.Row.Index)
Dim dt1 As Date = r("启动日期")
Dim dt2 As Date = r("完成时间")
Dim dt As Date = e.Col.Name.Replace("年","-").Replace("月_","-")
Dim t2 As Table = e.Table
Dim nm As String = dt2.Year & "年" & dt.Month &"月_" & dt.Day
Dim idx As Integer= t2.cols(nm).Index
Dim sp As TimeSpan = dt2 - dt1
Dim idx1 As Integer = r("进度")/100 * sp.TotalDays
Dim dt3 As Date = dt1.AddDays(idx1)
If dt>=dt1 AndAlso dt<=dt2 Then
e.StartDraw()
If dt < Date.Today Then
e.Graphics.FillRectangle(Brushes.springGreen,e.x ,e.y + 5, e.Width, e.Height - 10)
Else
e.Graphics.FillRectangle(Brushes.lightskyblue,e.x ,e.y + 3, e.Width, e.Height - 10)
End If
If dt>=dt1 AndAlso dt <= dt3 Then
e.Graphics.FillRectangle(Brushes.gold,e.x ,e.y + 2, e.Width, e.Height - 10)
End If
e.EndDraw()
End If
End If