以下是引用yaojun在2019/6/10 9:40:00的发言:
甜老师您好,以上实例对我非常实用,但是修改数据后需要重新打开窗口才会刷新,请问:假如做一个按钮,增加一段怎样的代码可以实现自动刷新,不需要重新打开窗口,数据就能更新,谢谢
执行代码
Functions.Execute("BuildGanttTable")
With Tables("窗口1_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("窗口1_Table2")
tb.Grid.MergedRanges.clear
tb.Grid.AllowMerging = C1.Win.C1FlexGrid.AllowMergingEnum.Custom
Dim minD As Date = Tables("任务").Compute("min(开始日期)")
For i As Integer = tb.HeaderRows To tb.Rows.Count
Dim r As Row = Tables("任务").Rows(i-2)
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