[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

VB5: TreeView / ListView / ImageList

Posted on 1998-04-18
4
Medium Priority
?
705 Views
Last Modified: 2008-03-17
I'm looking for a good sample app that shows how to use TreeView, ListView, and Image View to create your own custom file/dir list box.  The example should utilize every feature of these controls so I see exactly how everything works.  Either post the code here, e-mail it to me at ChrisK@yankton.com, or point to a web site that has the example I seek.  Thanks...
0
Comment
Question by:ChrisK
  • 2
4 Comments
 

Expert Comment

by:tlw2651
ID: 1425060
This piece of code comes from the Enterprise edition Books Online.  I found it helpful... It works with the Biblio.mdb sample database that comes with VB 5.0


' General Declarations
Private mDbBiblio As Database ' Database variable.

Private Sub Form_Load()
      ' Open the Biblio.mdb and set the object variable
      ' to the database.
      Set mDbBiblio = DBEngine.Workspaces(0). _
      OpenDatabase("Biblio.mdb")

      ' Code to populate the TreeView control
      ' isn't shown here.
End Sub

Private Sub tvwDB_NodeClick(ByVal Node As Node)
      ' Check the Tag for "Publisher." If so, then
      ' call the MakeColumns procedure and then the
      ' GetTitles function.
      If Node.Tag = "Publisher" Then
            MakeColumns
            GetTitles Val(Node.Key)
      End If
End Sub

Private Sub MakeColumns()
      ' Clear the ColumnHeaders collection.
      lvwDB.ColumnHeaders.Clear
      ' Add four ColumnHeaders.
      lvwDB.ColumnHeaders.Add , , "Title", 2000
      lvwDB.ColumnHeaders.Add , , "Author"
      lvwDB.ColumnHeaders.Add , , "Year", 350
      lvwDB.ColumnHeaders.Add , , "ISBN"
End Sub

Private Sub GetTitles(PubID)
' Clear the old titles.
lvwDB.ListItems.Clear
' Declare object variable of type Recordset.
Dim rsTitles As Recordset
' While on this record, create a recordset using a
' query that finds only titles that have the same
' PubID. For each record in this recordset, add a
' ListItem object to the ListView control, and set
' the new object's properties with the record's
' Title, ISBN, and Author fields.
Set rsTitles = mDbBiblio.OpenRecordset _
("select * from Titles where PubID = " & PubID)

Do Until rsTitles.EOF
' Add ListItem.
            Set mItem = lvwDB.ListItems.Add()
            mItem.Text = rsTitles!TITLE
            mItem.SmallIcon = "smlBook"
            mItem.Icon = "book"      
            mItem.Key = rsTitles!ISBN
            ' Use a function to get the author and set
            ' the SubItems(1) property.
            mItem.SubItems(1) = GetAuthor(rsTitles!ISBN)
            If Not IsNull(rsTitles![Year Published]) Then
                  mItem.SubItems(2) =  _
            rsTitles![Year Published]
            End If
            mItem.SubItems(3) = rsTitles!ISBN
            rsTitles.MoveNext
Loop
End Sub

Private Function GetAuthor(ISBN)
      ' Declare DAO object variables.
      Dim rsTitleAuthor As Recordset
      Dim rsAuthors As Recordset    
      ' Set object variables to recordsets.
      Set rsTitleAuthor = mDbBiblio. _
      OpenRecordset("Title Author", dbOpenDynaset)
      Set rsAuthors = mDbBiblio. _
      OpenRecordset("Authors", dbOpenDynaset)
      ' Create query string.
      Dim strQuery As String
      strQuery = "ISBN = " & "'" & ISBN & "'"
      rsTitleAuthor.FindFirst strQuery
      ' If there is no author, return "n/a."
      ' Otherwise, return the name of the author.

      If rsTitleAuthor.NoMatch Then
            GetAuthor = "n/a"
            Exit Function
      Else
            ' Presume we have found the right recordset.
            ' Then reset the string query with Au_ID
            ' field value and search "Authors" table.
            strQuery = "Au_ID = " & rsTitleAuthor!AU_ID
            rsAuthors.FindFirst strQuery
            ' Return the name of the author from the Author
            ' field.
            GetAuthor = rsAuthors!Author
      End If
End Function
      

0
 
LVL 2

Author Comment

by:ChrisK
ID: 1425061
I've got biblio.mdb and tried setting up the forms but it's not working.  Please send me this example in a vb form/project via e-mail.  Send to ChrisK@yankton.com
0
 
LVL 2

Author Comment

by:ChrisK
ID: 1425062
OK, I just found the project under the vb5 samples that uses biblio.mdb with treeview...unfortunetly it doesn't help me out much.  I need an example that uses file listings, not information out of a database.  The whole goal here is to emulate the drive/dir/file list boxes so I can customize them with icons and other things.
0
 
LVL 1

Accepted Solution

by:
MAVERICK earned 140 total points
ID: 1425063
I have an OCX which may help you!
You can get it from www.Comcache.com
 
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I’ve seen a number of people looking for examples of how to access web services from VB6.  I’ve been using a test harness I built in VB6 (using many resources I found online) that I use for small projects to work out how to communicate with web serv…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Suggested Courses
Course of the Month18 days, 23 hours left to enroll

834 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