Results 1 to 4 of 4

Thread: [2005] Combobox with Optical Drives

  1. #1

    Thread Starter
    Junior Member
    Join Date
    May 2007
    Posts
    21

    [2005] Combobox with Optical Drives

    Hello,

    I have to rewrite a program that I previously made in VB6 in VB.Net 2005. I would like to have a combobox with only the available optical (CD/DVD) drives listed. How is this done in VB.NET? Any help or direction is greatly appreciated.

    Thanks

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

    Re: [2005] Combobox with Optical Drives

    vb.net Code:
    1. Dim opticalDrives As New List(Of IO.DriveInfo)
    2.  
    3. For Each drive As IO.DriveInfo In IO.DriveInfo.GetDrives()
    4.     If drive.DriveType = IO.DriveType.CDRom Then
    5.         opticalDrives.Add(drive)
    6.     End If
    7. Next drive
    8.  
    9. With Me.ComboBox1
    10.     .ValueMember = "Name"
    11.     .DataSource = opticalDrives
    12. End With
    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
    Junior Member
    Join Date
    May 2007
    Posts
    21

    Re: [2005] Combobox with Optical Drives

    Thanks jmcilhinney for your help..It works great. One more question. It currently listes the drive letter, is it possible to list the drive letter AND the title of the disc thats in the drive?

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

    Re: [2005] Combobox with Optical Drives

    The VolumeLabel property of the DriveInfo object returns the disc name. If you want both the letter and the label you'd have to combine them yourself and then add them to the 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

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