在DataColChanged事件里编写了如下代码,还是无法实现自动增加列,请老师帮忙看看代码哪里写错了!
Select Case e.DataCol.Name
Case "预计完工日期"
Dim tbl1 As DataTable = DataTables("生产计划_订单表")
Dim EndDate1 As Date = tbl1.SQLCompute("Max(预计完工日期)")
If e.NewValue > EndDate1 Then
Dim dt As Date = EndDate1
Do
Dim nm As String = "甘特图" & dt.Year & "年" & dt.Month & "月_" & dt.Day + 1
Dim Builder As New ADOXBuilder
Builder.Open() '打开ADOXBuilder
With Builder.Tables("生产计划_订单表甘特图")
.AddColumn(nm,ADOXType.String,16)
End With
Builder.Close()
dt = dt.Adddays(1)
If dt > e.NewValue Then
Exit Do
End If
Loop
For Each cl As Col In Tables("生产计划_订单表甘特图").Cols
cl.width = 20
Next
For Each dd As DataTable In DataTables
dd.Save()
Next
End If
End Select