Populating listview from a database

databases United States
  • 19 years ago

    I have a listbox and a listview control on a form.  How do you code the ItemData property so that when you click on one of the instructor names in the listbox, only the names of the students taught by that instructor show in the listview box?

  • 19 years ago

    Hi!


    I might be dumb.... but what is a listview control? Something similar to a treeview...?


    In VBA for MsAccess it would be quite simple, i'm not sure how the Data Gatering works under VB yet..


    Let me know if you are still interested in knowing the Access solution...


    Regards,

  • 19 years ago

    Dear Reptile,


    You are absolutely right.  Listview is very similar to Treeview in VB6.  If you open Windows Explorer you will see a listbox on the left where you select your drive or directory.  The box on the right is the listview box where you see the contents of that drive or directory.  


    The basic differences between listview and treeview are that with treeview you have nodes, wheres with listview has listitems.  Also you have pictures/icons with with treeview, whereas you can use both large and small icons with listview.  The beauty about listview is that you have four different display styles - large icons, small icons, list and details.  You will see all four in Windows Explorer.  


    Thanks for your offer to show me the Access solution to my question.  I'm a bit of a rookie, so I think I had better stick with VB6, and not get into VBA just yet.  


    Regards,
    Veronica

  • 19 years ago

    I'm not sure there is a ListView method to hide certain nodes
    of the listview, based on a filtering ... my impression (wrong?) is that you have to do it yourself, by deleting from the listview all items not fulfilling your condition.


    Maybe if your source data is in a recordset, the fastest thing is to filter the recordset and passit to a PopulateListview function.


  • 19 years ago

    Dear Hobbes68


    Thank you for your contribution.  I solved the problem by using the ItemData property to access the index number of the selection made in the listbox.  When I called the records from the database, only the ones that matched the index number appeared in the listview.


    Thanks again,
    Veronica

Post a reply

Enter your message below

Sign in or Join us (it's free).

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Weeks of coding can save you hours of planning.”