Solved

How to incorporate Tree in VideoSoft Grid 7

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Pull multiple cvs files into one access table 28 65
Input past end of file vbs script 9 83
Run code from text file in vb 1 57
how to know if my Checkbox is True in VB6.0? 9 41
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

863 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

24 Experts available now in Live!

Get 1:1 Help Now