static dic As new Dictionary(of String, brush)
If DrawGannt Then
Dim cr As Row = Tables("任务").Rows(e.Row.Index)
For Each r As DataRow In cr.Table.DataTable.Select("工程名称 = '" & cr("工程名称") & "'", "开始日期")
Dim dt1 As Date = r("开始日期")
Dim dt3 As Date = r("实际开始")
Dim dt2 As Date = r("结束日期")
Dim dt As Date = e.Col.Name.Replace("年","-").Replace("月_","-")
If dt = dt1 Then
e.StartDraw()
If dic.ContainsKey(dt) = False Then
Dim br1 As Brush = New SolidBrush(Color.FromARGB(rand.Next(255),rand.Next(255),rand.Next(255),rand.Next(255)))
dic.add(dt, br1)
End If
Dim sp1 As TimeSpan = dt3-dt1
Dim sp2 As TimeSpan = dt2-dt3
Dim sp3 As TimeSpan = dt2-dt1
e.Graphics.FillRectangle(dic(dt),e.x ,e.y + 5, cint(e.Width*sp1.TotalDays/sp3.TotalDays), e.Height - 10)
If dt3 <> Nothing Then
Dim br2 As Brush = New SolidBrush(Color.green)
e.Graphics.FillRectangle(br2,e.x+cint(e.Width*sp1.TotalDays/sp3.TotalDays) ,e.y + 5, cint(e.Width*sp2.TotalDays/sp3.TotalDays), e.Height - 10)
End If
Dim fnt As New Font("宋体",9)
Dim msg As String = r("任务名称")
e.Graphics.DrawString(msg,fnt,Brushes.Red,e.x,e.y+2)
e.EndDraw()
End If
Next
End If