+ Reply to Thread
Results 1 to 6 of 6

Listbox with Categories (code solution)

  1. #1
    Forum Contributor
    Join Date
    04-12-2006
    Location
    Morgan Hill CA
    Posts
    107

    Listbox with Categories (code solution)

    I could not find an appropriate ListBox that supported expandable & collapseable categories with items under them (like many File Explorers) and I really needed one with what I was doing.

    I did not like the 2 Listbox option - where the first listbox has the categories in it that when clicked shows the items under that category in a second listbox.

    I did not want to use an external control or interface with a DLL.........

    so I wrote one.... It uses a standard listbox control and the code manipulates categories / items (single level only)

    Looks like the following, in the listbox
    + Category One
    - Category Two
    Item One - Category Two
    Item Two - Category Two
    + Category Three

    Double clicking a category expands/collapses
    Double clicking an item will return the "category * item"
    Keyboard methods work as well (up/down, return key)

    The init method documents how to add categories and items. After that the code goes about expanding and collapseing. Add your methods for dealing with selected items.

    Works for me -- If anyone is interested, I'd be willing to share, PM me.

  2. #2
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Listbox with Categories (code solution)

    There is a TreeView control but it's not easy to use
    Hope that helps.

    RoyUK
    --------
    For Excel Tips & Solutions, free examples and tutorials why not check out my web site

    Free DataBaseForm example

  3. #3
    Forum Contributor
    Join Date
    04-12-2006
    Location
    Morgan Hill CA
    Posts
    107

    Re: Listbox with Categories (code solution)

    Is this a part of the toolbox in VBA? Can you point me to it? I searched on various forums and no one mentioned this before.

    Thanks,

  4. #4
    Forum Contributor
    Join Date
    04-12-2006
    Location
    Morgan Hill CA
    Posts
    107

    Re: Listbox with Categories (code solution)

    I found a post with the appropriate controls that are required for this
    Microsoft TreeView Control
    but do not have this on my control system, and when I install this on a users system - they may not have it on their system either??? Hmmm....

    ... and I don't even have this control on my current system - I'm using Excel 2003 to develop.

    Thanks,

  5. #5
    Forum Expert royUK's Avatar
    Join Date
    11-18-2003
    Location
    Derbyshire,UK
    MS-Off Ver
    Xp; 2007; 2010
    Posts
    26,200

    Re: Listbox with Categories (code solution)

    In the VB Editor insert a UserForm, then in Tools Dialog, right click & select Additional Controls. Scroll down to find the TreeView

  6. #6
    Forum Contributor
    Join Date
    04-12-2006
    Location
    Morgan Hill CA
    Posts
    107

    Re: Listbox with Categories (code solution)

    Excellent - thanks.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1