简体   繁体   中英

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

I am getting both the folder directory and the folder's name in the same column, how do I make them separate into different columns?

This should load the ComboBox and the DataGridView as you requested:

    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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM