Solved

VB5: TreeView / ListView / ImageList

Posted on 1998-04-18
4
653 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 70 total points
ID: 1425063
I have an OCX which may help you!
You can get it from www.Comcache.com
 
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

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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 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…
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…

920 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

12 Experts available now in Live!

Get 1:1 Help Now