?
Solved

VB5: TreeView / ListView / ImageList

Posted on 1998-04-18
4
Medium Priority
?
690 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
[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
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses
Course of the Month10 days, left to enroll

762 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