Results 1 to 6 of 6

Thread: Folders in Listbox?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2009
    Posts
    78

    Folders in Listbox?

    Is it possible to have folders in a toolstripdropdownbutton? if so, how?

    thanks

    also, I know there was a thread before, but it didn't work for me:

    how do I get a drag and drop for my listbox? it is called listbox2 could someone give me the exact coding for it?

    i found a thread before but nothing happened when I put the code in, and I changed the name properly too and stuff

    thanks

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Folders in Listbox?

    First up, please keep each thread to a single topic and each topic to a single thread. You have two questions that are unrelated so they belong in separate threads.

    With regards to the first question, do you know how to add a menu item in code? If so then you simply call IO.Directory.GetDirectories to get a String array containing all the subfolders of a folder, which you can then loop through and create a menu item for each.

    With regards to the second question, there's not much point our providing you the exact code when you say that you've already got the exact code and it doesn't work. You need to show us exactly what you've done and, ideally, provide us with a link to where you got it from in the first place so that we can compare and point out your error if there is one. I've provided drag and drop code for a ListBox in the VB.NET CodeBank forum but, for all I know, that's the exact code that you've already found. If you'd like to check it out to see if it's better than what you currently have, follow the CodeBank link in my signature.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2009
    Posts
    78

    Re: Folders in Listbox?

    sorry about 2 question thing won't do again

    Yes I think I got that code, but it doesn't work for me nothing happens, so I thought it was actually for something else

    However, I don't know about the folder thing is there somewhere I can get info on it? (like what is the "official" name for it?
    And can I still save under my.settings?

  4. #4
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Folders in Listbox?

    You need to be bit clearer about what exactly you want. Save what in My.Settings exactly?

    I'm on a phone at the moment so writing code's a bit of a challenge, but here goes:
    Code:
    For Each folder As String In IO.Directory.GetDirectories("folder path here")
        myToolButton.DropDownItems.Add(folder, Nothing, AddressOf ClickHandler)
    Next
    or something fairly close to that.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  5. #5

    Thread Starter
    Lively Member
    Join Date
    Dec 2009
    Posts
    78

    Re: Folders in Listbox?

    Hmmmm, where it says folder path here, is that just te folder path to the file?

    I saw one project with a XML document and I copied the file (the XML file) into the same subfolder in my protect and copied the code but nothing happened

    is there and example of that somewhere?

    And regarding my.settings normally I save all the stuff I have to load up in a string or speciallised sting collection in my. Settings

    but with folders could I still save there or would I have to have some different kind of saving file? (like the XML thing )

  6. #6
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Folders in Listbox?

    First up, if it says "folder path here" then you're supposed to put the folder path there. If you're trying to get a list of folders then a file path isn't relevant, is it? It's the path of the parent folder.

    As for saving to your settings, a folder path is just a string, so it gets treated like any other string.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Tags for this Thread

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