Solved

How to incorporate Tree in VideoSoft Grid 7

Posted on 2002-04-30
1
640 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
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…
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…
Suggested Courses
Course of the Month9 days, 3 hours left to enroll

615 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