Results 1 to 4 of 4

Thread: File icons into a listbox

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878

    Question

    I asked this half an hour ago, but I then deleted it as I thought I had found the answer at :
    http://www.vbsquare.com/tips/tip289.html
    But it doesn't quite give me what I want.....

    I have a listbox with a list of files in it.
    I need to add the icon of the file into the front of the list box. The icon being based on the file type, e.g. .DOC, .XLS, .MSG, .TXT, .EXE etc.

    The code referenced above adds the icon into a picture box - but I can't do a ListBox.AddItem to get it into the listbox.

    Thanks for any help,

    Chris

  2. #2
    Retired VBF Adm1nistrator plenderj's Avatar
    Join Date
    Jan 2001
    Location
    Dublin, Ireland
    Posts
    10,359
    Use a ListView.
    Looks nearly the same, but allows you to add icons.

    - jamie
    Microsoft MVP : Visual Developer - Visual Basic [2004-2005]

  3. #3
    Fanatic Member crispin's Avatar
    Join Date
    Aug 2000
    Location
    2 clicks west of a Quirkafleeg...Cornwall, England
    Posts
    754
    Brad Martinez is a bit of a god at this sort of thing, as plenderj said, best to use a listview, the next thing is to work out how to take the default icons of the files you want and add them to imagelist - one answer is to use the windows system imagelist, heres some example code (fairly complex)

    http://www.mvps.org/btmtz/listview/systemimagelist.zip

    hope this helps
    Crispin
    VB6 ENT SP5
    VB.NET
    W2K ADV SVR SP3
    WWW.BLOCKSOFT.CO.UK

    [Microsoft Basic: 1976-2001, RIP]

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Jan 2001
    Location
    Newbury, UK
    Posts
    1,878
    Thanks Jamie....

    That pointer and this information:
    http://www.mvps.org/vbnet/index.html
    seems to have solved it for me.

    Cheers, Chris

Posting Permissions

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



Click Here to Expand Forum to Full Width