具有驱动器名称的组合框? [英] Combobox with drive name?
问题描述
好的,经过一段时间的尝试和错误,我现在想在我的图像组合框中添加一些细节.它以正确的顺序显示系统图标,但是紧接在图标之后,我希望用户输入驱动器名称,然后显示要显示的驱动器号,而不仅仅是驱动器号.任何人都可以朝我的方向放一些代码以按此顺序放置它吗?
再次感谢大家的帮助! (假定某人有答案)
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)
推荐答案
我从没做过,但是根据google,您是这样做的:
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 & " " )
Console.WriteLine(drive_info.RootDirectory.ToString)
If drive_info.IsReady() Then
Console.WriteLine( drive_info.VolumeLabel())
End If
Next drive_info
End Sub
End Class
克里斯蒂安(Christian)显示了正确的方法要获取驱动器信息,只需将方法应用于您要如何显示或使用所提供的信息即可.
根据您的情况,将console.write
替换为ComboBox1.Items.Add
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 theconsole.write
withComboBox1.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.
Regards
这篇关于具有驱动器名称的组合框?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!