簡體   English   中英

如何在vb.net中為數組設置新屬性?

[英]How to set a new property for an array in 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

我在同一列中同時獲得了文件夾目錄和文件夾名稱,如何將它們分成不同的列?

這應該按照您的要求加載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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM