Solved

How to incorporate Tree in VideoSoft Grid 7

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

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

Suggested Solutions

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
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…

757 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

22 Experts available now in Live!

Get 1:1 Help Now