Solved

VB5: TreeView / ListView / ImageList

Posted on 1998-04-18
4
680 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 70 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: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…

690 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