Solved

How to incorporate Tree in VideoSoft Grid 7

Posted on 2002-04-30
1
616 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

Suggested Solutions

Background What I'm presenting in this article is the result of 2 conditions in my work area: We have a SQL Server production environment but no development or test environment; andWe have an MS Access front end using tables in SQL Server but we a…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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 process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

815 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now