此主题相关图片如下:未命名2.png
在老师的指导下,甘特图完成的差不多了,但还有一个问题一直未解决,同一个班组的两个排产内容合并到一行后,进度条显示异常,没有完全跟到日期,怎么解决?另外能不能做到同一个班组的两个排产内容合并到一行后是两个不同的颜色
此主题相关图片如下:未命名.png
甘特图表drawcell代码:
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 dt2 As Date = r("结束日期")
Dim dt As Date = e.Col.Name.Replace("年","-").Replace("月_","-")
If dt = dt1 Then
e.StartDraw()
e.Graphics.FillRectangle(Brushes.RoyalBlue,e.x ,e.y , e.Width , e.Height)
Dim fnt As New Font("宋体",9)
Dim msg As String = r("排产内容")
e.Graphics.DrawString(msg,fnt,Brushes.LightGreen,e.x,e.y+2)
e.EndDraw()
End If
Next
End If
合并显示按钮代码:
Tables("生产计划").RepeatFilter("班组", 1)
Functions.Execute("BuildGanttTable")
With Tables("甘特图_Table2").Grid
.FocusRect = C1.Win.C1FlexGrid.FocusRectEnum.None '不显示焦点框
.HighLight = C1.Win.C1FlexGrid.HighLightEnum.Never '不高亮显示选定区
.SelectionMode = C1.Win.C1FlexGrid.SelectionModeEnum.Cell '每次只显示一个单元格
End With
Dim tb As Table = Tables("甘特图_Table2")
tb.Grid.AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.Custom
Dim minD As Date = Tables("生产计划").Compute("min(开始日期)")
Dim ls As new List(of object)
For Each r As object In tb.Grid.MergedRanges
ls.add(r)
Next
For Each r As object In ls
tb.Grid.MergedRanges.Remove(r)
Next
For i As Integer = tb.HeaderRows To tb.Rows.Count+tb.HeaderRows
Dim cr As Row = Tables("生产计划").Rows(i-2)
For Each r As DataRow In cr.Table.DataTable.Select("班组 = '" & cr("班组") & "'", "开始日期")
Dim dt1 As Date = r("开始日期")
Dim dt2 As Date = r("结束日期")
Dim sp As TimeSpan = dt2 - dt1
Dim sp2 As TimeSpan = dt1 - minD
Dim rng As C1.Win.C1FlexGrid.CellRange = tb.Grid.GetCellRange(i, sp2.TotalDays+1, i, sp2.TotalDays+1+sp.TotalDays)
tb.Grid.MergedRanges.add(rng)
Next
Next
[此贴子已经被作者于2018/5/25 9:46:24编辑过]