我想实现树形的grid,请问应该怎么做?

解决方案 »

  1.   

    那么如何显示呢?
    我查了资料,vsflexgrid和Mshflexgrid这2个控件都支持分层显示数据,可是我应该怎么做呢?
    多谢指教
      

  2.   

    'fa is vsflexgrid
    fa.Rows = 1
        fa.FixedRows = 1
        fa.Cols = 3
        fa.AllowUserResizing = flexResizeBoth
        fa.ExtendLastCol = True
        fa.OutlineBar = flexOutlineBarComplete
        fa.OutlineCol = 0
        fa.SubtotalPosition = flexSTAbove
        
        ' fill the control with data
        fa.Cell(flexcpText, 0, 0) = "Heading"
        fa.Cell(flexcpText, 0, 1) = "Date"
        fa.Cell(flexcpText, 0, 2) = "Time"
        Dim i%, j%
        While fa.Rows < 150
            
            ' decide randomly whether to add a subtotal
            If fa.Rows <= 2 Or Rnd() < 0.4 Then
            
                ' add an item, make it a subtotal
                fa.AddItem "Branch Level " & i
                fa.IsSubtotal(fa.Rows - 1) = True
                fa.RowOutlineLevel(fa.Rows - 1) = i
                fa.Cell(flexcpPicture, fa.Rows - 1, 0) = imgFolder
                j = i
                
                ' decide whether to go deeper or shallower
                If Rnd() < 0.5 And i < 10 Then
                    i = i + 1
                ElseIf Rnd() < 0.5 And i > 0 Then
                    i = i - 1
                End If
            
            ' add a regular item
            Else
                fa.AddItem "Data on Level " & j & vbTab & Date & vbTab & Time
                fa.Cell(flexcpPicture, fa.Rows - 1, 0) = imgItem
            End If
        Wend
        
        ' add some more data just for kicks
        For i = 1 To 10
            fa.AddItem "Data on Level " & j & vbTab & Date & vbTab & Time
            fa.Cell(flexcpPicture, fa.Rows - 1, 0) = imgItem
        Next
        
        ' do an autosize
        fa.AutoSize 0, 1, , 300
      

  3.   

    to  fishmans(金脚指):
    你好,上面的程序中imgFolder和imgItem都是什么?是不是image控件?