如何在vb.net中为数组设置新属性?

时间:2013-11-18 01:30:08

标签: arrays vb.net

Dim SteamGames As New Dictionary(Of String, String)
For Each Game As String In System.IO.Directory.GetDirectories(Me.tb_SteamDir.Text)
    SteamGames.Add(Game, System.IO.Path.GetFileName(Game))
Next Game

For Each Pair As KeyValuePair(Of String, String) In SteamGames
    dgv_Table.Rows.Add(Pair.Key)
    dgv_Table.Rows.Add(Pair.Value)
Next Pair

我在同一列中同时获取文件夹目录和文件夹名称,如何将它们分成不同的列?

1 个答案:

答案 0 :(得分:0)

这应该按照您的要求加载ComboBox和DataGridView:

    Dim DT As New DataTable
    DT.Columns.Add("Full Path")
    Dim GameNames_Master As New List(Of String)
    For Each Dir As DirectoryInfo In New DirectoryInfo(Me.tb_SteamDir.Text).GetDirectories
        GameNames_Master.Add(Dir.Name)
        DT.Rows.Add(New Object() {Dir.FullName})
    Next Dir
    dgv_Table.DataSource = DT
    Me.cb_Games.DataSource = GameNames_Master