我想一个表中的数据用VSFLEXGRID显示,类似treeview进行分类和合并,要能扩展和缩小,无法完全实现,所以请大家指点。最好给个比较类似例子。谢谢!
[email protected]

解决方案 »

  1.   

    如果是加载数据后自动组成树,请使用SubTotal方法如果是手动加载成树,可以看一个GRID里面有一个NODE对象,不是很复杂。
    也可以不用NODE对象,直接用GRID组成有可以!可以看一些DEMO!
      

  2.   

    楼上:
        无法设置NODE对象,请给个例子好吗?
      

  3.   

    要显示tree结构,看其中的两个form就可以了,frmexplo 和frmnew6
      

  4.   

    我实现了此功能,只是觉得比较笨的方法,不知是否有更好的方法,希望大家指点!bj = "select 公司,部门,科室,部门编号 from department GROUP BY 公司,部门,科室,部门编号" 'append ({select 科室 from department where 部门=?} AS chapter relate 部门 to parameter 0)"'  Set adodc.recordset = New ADODB.Recordset
    '  adodc.recordset.Open bj, ConnectIDD, adOpenKeyset, adLockPessimistic
      Adodc.RecordSource = bj
      Adodc.Refresh
      
      If Not (Adodc.Recordset.EOF And Adodc.Recordset.BOF) Then
        i = Adodc.Recordset.RecordCount
        Adodc.Recordset.MoveFirst
        
      With VSFlexQuery
         .Rows = 0
            .AddItem "部门分类" & vbTab & "部门编号"
           ' .Cell(flexcpPicture, .Rows - 1) = imgComputer
            .IsSubtotal(.Rows - 1) = True
            
            
           
        For a = 1 To i
          ' Debug.Print Adodc.Recordset.Fields(0)
            'Debug.Print Adodc.Recordset.Fields(2)
           If (STR <> Adodc.Recordset.Fields(0)) And (IsNull(Adodc.Recordset.Fields(0)) = False) Then         .AddItem Adodc.Recordset.Fields(0) & vbTab & Adodc.Recordset.Fields(3)
             
             .IsSubtotal(.Rows - 1) = True
             .RowOutlineLevel(.Rows - 1) = 1
            '  VSFlexQuery.GetNode(.Rows - 1).Expanded = False
           End If
               If (Field2 <> Adodc.Recordset.Fields(1)) And IsNull(Adodc.Recordset.Fields(1)) = False Then
                 .AddItem Adodc.Recordset.Fields(1) & vbTab & Adodc.Recordset.Fields(3) '& vbTab & Adodc.Recordset.Fields(3)
                 .Cell(flexcpBackColor, .Rows - 1, 1) = &HF0F0F0             .IsSubtotal(.Rows - 1) = True
                 .RowOutlineLevel(.Rows - 1) = 2
               End If
                 If Adodc.Recordset.Fields(2) <> "" Then
                    .AddItem Adodc.Recordset.Fields(2) & vbTab & Adodc.Recordset.Fields(3)
                    .IsSubtotal(.Rows - 1) = True
                 
                    .RowOutlineLevel(.Rows - 1) = 3
                 End If
               '  VSFlexQuery.GetNode(.Rows - 1).Expanded = False
               If IsNull(Adodc.Recordset.Fields(1)) = False Then
                 Field2 = (Adodc.Recordset.Fields(1))
               End If
          STR = Adodc.Recordset.Fields(0)
          Adodc.Recordset.MoveNext
        Next a
      ' VSFlexQuery.GetNode(.Rows - 1).Expanded = False
     End With
      End If
      'VSFlexQuery.GetNode(0).Expanded = False
      VSFlexQuery.GetNode(1).Expanded = False