Dim t As Table=Tables("生产计划单_t4")
t.Fill("sel ect 订单号 from {计划明细} where [_Identify]=0",Functions.Execute("返回数据源"),True)
TblBase = t.Grid
t.StopRedraw
With TblBase
'' .Font = New Font("微软雅黑",9)
.SubtotalPosition = C1FlexGrid.SubtotalPositionEnum.AboveData
.AllowFreezing = C1FlexGrid.AllowFreezingEnum.None
.AllowResizing = C1FlexGrid.AllowResizingEnum.Columns
.VisualStyle = C1FlexGrid.VisualStyle.System
.Tree.Column = 1
.Tree.LineStyle = Drawing2D.DashStyle.Dash
.Tree.Style = C1FlexGrid.TreeStyleFlags.CompleteLeaf
' .Tree.NodeImageCollapsed = GetImage("0.png")
' .Tree.NodeImageExpanded = GetImage("1.png")
.Cols(0).AllowResizing = False
.Cols(0).TextAlign = C1FlexGrid.TextAlignEnum.CenterCenter
End With
t.DataTable.DataRows.Clear
With Tables("生产计划单")
If .current IsNot Nothing Then
Dim Node As C1FlexGrid.Node
Dim s As String
Dim cl As String
For Each r As DataRow In DataTables("计划明细").Select("计划单号='" & .current("计划单号") & "'","排程顺序,级码")
If r("级码").split(".").length=1 Then
Node = TblBase.Rows.InsertNode(TblBase.Rows.Count, 0)
For Each c As Col In Tables("计划明细").Cols
If t.DataTable.DataCols.Contains(c.name)=False Then
t.DataTable.DataCols.add(c.name,Gettype(String),255)
End If
node.Row(c.name)=r(c.name)
Next
Else
If r("订单号")=node.Row("订单号") Then
Node = TblBase.Rows.InsertNode(TblBase.Rows.Count, 1)
For Each c As Col In Tables("计划明细").Cols
If t.DataTable.DataCols.Contains(c.name)=False Then
t.DataTable.DataCols.add(c.name,Gettype(String),255)
End If
node.Row(c.name)=r(c.name)
Next
End If
End If
'' Functions.Execute("loop", node)
Next
End If
End With
vars("展开")=1
t.Cols(t.Cols(0).name).Width=120
t.ResumeRedraw
这是生成C1FlexGrid目录树表的代码 如果数据超过5行就已经非常卡了 30行简直要命 有什么优化方法,这个树只有2层,是固定的,根据级码和订单号进行父子关联