Results 1 to 6 of 6

Thread: [RESOLVED] [2003] Populating a ComboBox with drives

  1. #1

    Thread Starter
    Lively Member therat324's Avatar
    Join Date
    Oct 2008
    Location
    Bethany, Oklahoma
    Posts
    94

    Resolved [RESOLVED] [2003] Populating a ComboBox with drives

    Im trying to populate a combobox with a list of the drives located in "My Computer"

    So each drive would have an item and text

    How would I go about doing this?

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

    Re: [2003] Populating a ComboBox with drives

    Call DriveInfo.GetDrives and bind the result to your ComboBox.
    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
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: [2003] Populating a ComboBox with drives

    Oops! Just after I posted I realised that you're using .NET 1.1 so the DriveInfo class is not available to you.
    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

  4. #4

    Thread Starter
    Lively Member therat324's Avatar
    Join Date
    Oct 2008
    Location
    Bethany, Oklahoma
    Posts
    94

    Re: [2003] Populating a ComboBox with drives

    LAME! lol I was getting excited because I'd never heard of a driveInfo class

  5. #5
    PowerPoster JuggaloBrotha's Avatar
    Join Date
    Sep 2005
    Location
    Lansing, MI; USA
    Posts
    4,286

    Re: [2003] Populating a ComboBox with drives

    It's in the Environment class, been there since .Net 1.0 (VS 2002):
    Code:
            For Each Drive As String In Environment.GetLogicalDrives
                MessageBox.Show(Drive)
            Next Drive
    What you can do is bind the ComboBox to the Environment.GetLogicalDrives array and there ya go.
    Currently using VS 2015 Enterprise on Win10 Enterprise x64.

    CodeBank: All ThreadsColors ComboBoxFading & Gradient FormMoveItemListBox/MoveItemListViewMultilineListBoxMenuButtonToolStripCheckBoxStart with Windows

  6. #6

    Thread Starter
    Lively Member therat324's Avatar
    Join Date
    Oct 2008
    Location
    Bethany, Oklahoma
    Posts
    94

    Re: [2003] Populating a ComboBox with drives

    Thank you very much. Works great now
    My car if Chevy was VB.NET

    Code:
    Public Class MyCar
        Public Sub Camaro()
            Dim Camaro As Car
            Camaro = SS.Fast("Sexy")
        End Sub
    
        Public Function Fast(ByVal sexy As String ) As String
            Return "SUPER" & sexy
        End Function
    End Class

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