Solved

How to incorporate Tree in VideoSoft Grid 7

Posted on 2002-04-30
1
623 Views
Last Modified: 2012-08-13
How to incorporate Tree in VideoSoft Grid 7(VSFlex7). component one has given an example but that is related to XML. I am looking for a tree in VSFlex7 that get the information from the database. Please give me a detailed example of this.

Kindly help me out in this.

Sikandarali
0
Comment
Question by:sikandarali
1 Comment
 
LVL 18

Accepted Solution

by:
mdougan earned 50 total points
ID: 6983946
Here is a slightly hacked down sample from an application I wrote.  Should be better than there example.  Makes the grid look and act just like a TreeView control.  Not too fancy but what do you want for 50 points ;)

Private Sub Form_Load()
    With fgTree
       
        ' structure
        .Cols = 2
        .Rows = 0
        .FixedCols = 0
        .FixedRows = 0
        .ColWidth(1) = 0
       
        ' appearance
        .GridLines = flexGridNone
        .BackColorBkg = .BackColor
        .SheetBorder = .BackColor
        .ExtendLastCol = True
        .Redraw = flexRDBuffered ' << new setting
        .OutlineCol = 0
        .OutlineBar = flexOutlineBarCompleteLeaf
        .Ellipsis = flexEllipsisEnd
       
        ' behavior
        .AllowSelection = False
        .AllowBigSelection = False
        .HighLight = flexHighlightAlways
        .SelectionMode = flexSelectionListBox
        .ScrollTrack = True
        .AutoSearch = flexSearchFromCursor
   
    End With

End Sub

Public Sub FillTree()
' This routine loads the Accounts into the Tree control
Dim RS As ADODB.Recordset
Dim i As Long
Dim sSQL As String
Dim CurrentMaster As String

    On Error GoTo ErrorRtn
           

        fgTree.Redraw = flexRDDirect
' Clears out the tree/grid
        fgTree.Rows = 0
' Makes empty grid visible
        fgTree.Refresh
' Turns off redrawing while loading is occuring
        fgTree.Redraw = flexRDNone
       
' Format the sql statement to select salespeople within account
        sSQL = "SELECT"
        sSQL = sSQL & "  MASTER_ACCT.MASTER_ACCT_NAME,"
        sSQL = sSQL & "  MASTER_ACCT.M_ACCT,"
        sSQL = sSQL & "  SALESPERSON.SALESPERSON_NAME,"
        sSQL = sSQL & "  SALESPERSON.SALESPERSON_ID"
        sSQL = sSQL & "  FROM"
        sSQL = sSQL & "  MASTER_ACCT, SALESPERSON"
        sSQL = sSQL & "  WHERE"
        sSQL = sSQL & "  MASTER_ACCT.M_ACCT = SALESPERSON.M_ACCT"
        sSQL = sSQL & "  ORDER BY MASTER_ACCT.MASTER_ACCT_NAME, SALESPERSON.SALESPERSON_NAME"
   
        Set RS = New ADODB.Recordset
        CN.CursorLocation = adUseServer
   
        RS.Open sSQL, CN, adOpenForwardOnly, adLockReadOnly, adCmdText
' populate the tree
        While Not RS.BOF And Not RS.EOF
' If there has been a control break on Master Account add a folder node for a master account
            If StrComp(RS("M_ACCT"), CurrentMaster, vbTextCompare) <> 0 Then
                With fgTree
' Adds the Account name to the first column and stores the account number in the RowData property for use later
                    .AddItem RS("MASTER_ACCT_NAME") & " (" & RS("M_ACCT") & ")"
                    .RowData(.Rows - 1) = RS("M_ACCT")
' sets the picture to the picture in an image control on the screen
                    .Cell(flexcpPicture, .Rows - 1) = imgFolder
' A subtotal row is a row that is expandable
                    .IsSubtotal(.Rows - 1) = True
' Set the level of indentation
                    .RowOutlineLevel(.Rows - 1) = 1
                End With
' Save the current account number so we can detect the next master account break
                CurrentMaster = RS("M_ACCT")
            End If
           
' Now, add the item with the salesperson's name
            With fgTree
                .AddItem RS("SALESPERSON_NAME")
' Store the salesperson's id for use later when the user clicks on the item
                .RowData(.Rows - 1) = RS("SALESPERSON_ID")
                .Cell(flexcpPicture, .Rows - 1) = imgFile
' True or False depending on whether or not you're planning to put any sub-items under this level or not
                .IsSubtotal(.Rows - 1) = True
' This will indent the item under the master account
                .RowOutlineLevel(.Rows - 1) = 2
            End With
           
            RS.MoveNext
        Wend
       
        RS.Close

        If fgTree.Rows > 0 Then
       
' This causes the nodes with RowOutLinelevel = 1 to expand
            fgTree.Outline 1
' Now, allow the tree to redraw itself
            fgTree.Redraw = flexRDBuffered
                   
' Set the current row
            fgTree.Row = 0
' Force a RowColChange event to fire which is where we fill in the detail screen
            fgTree_RowColChange (0)
        Else
            MsgBox "No Master Accounts in the database", vbInformation, "View Master Accounts"
            fgTree_RowColChange (0)
            fgTree.Redraw = flexRDBuffered
        End If
           
ExitRtn:
    fgTree.Redraw = flexRDBuffered
    Exit Sub
ErrorRtn:
    MsgBox Err.Number & "-" & Err.Description
    Resume ExitRtn
   
End Sub

0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

828 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question