Click here to Skip to main content
15,790,723 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Ok after some time of trial and error I am now looking to add some detail to my image combobox. It displays system icons in the correct order but directly after the icon I would like the users drive name and then the drive letter to be displayed instead of just the drive letter. Can anyone shed a little code in my direction to place it in that order?

thank you once again all for your help!! (assuming that someone has an answer)

I've never done this, but according to google, you do it like this:

Imports System
Imports System.IO

Public Class MainClass
   Shared Sub Main()
        For Each drive_info As DriveInfo In DriveInfo.GetDrives()
            Console.Write(drive_info.Name & "   " )
            If drive_info.IsReady() Then
                Console.WriteLine( drive_info.VolumeLabel())
            End If
        Next drive_info
   End Sub
End Class
Share this answer
Dale 2012 7-Jul-11 3:46am    
I have tried this and maybe it does work but can you clarify combobox1 in place of console?
Dale 2012 7-Jul-11 3:47am    
how can I go about using this code for combobox?
Dave Kreskowiak 7-Jul-11 7:55am    
Seriously? You can't add a string to a combobox?

MyComboBox.Items.Add( myString )
S Houghtelin 7-Jul-11 7:55am    
This the correct method to use, OP needs to apply method to populating his combobox. +5
Christian showed the correct method to get the drive information, It is a matter of applying the method to how you want to display or use the information provided.

In your case, replace the console.write with ComboBox1.Items.Add
If drive_info.IsReady() Then
        ComboBox1.Items.Add(drive_info.Name & " " & drive_info.VolumeLabel())
End If

Christians example shows 3 ways to display the drive information, choose the one that serves your purpose.

Share this answer
Dale 2012 9-Jul-11 1:57am    
Your solution works a treat but I have mistaken my own question. I would like the combobox to display the text as follows:

Icon Localdrive C:\
Icon Seconddrive D:\
icon CdRom E:\

where as right now it only displays

Icon C:\
Icon D:\
icon E:\
Dale 2012 9-Jul-11 1:59am    
If the user has renamed the local drive C:\ to something like Windows 7 or the second drive D:\ to Backup then I would like the combobox to read the new volume name

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900