DataGridView不显示文本文件中的值

时间:2019-01-20 10:58:22

标签: vb.net datagridview

我在表单上有一个DataGridView,在加载表单时,它是从具有以下内容的文本文件中读取的:

Alpine Ice Arena:Birmingham Alabama:2000:3200:
Point Mallard Ice Rink:Decatur Alabama:3000:2500:
Florence Coliseum:Florence Alabama:1200:5000:

每行中第一个字段的值:
Apline Ice ArenaPoint Mallard Ice RinkFlorence Coliseum
表单加载时应显示在DataGridView中。
但是,这没有发生,我无法为自己的生活找出原因(尽管没有任何错误)。

我的代码如下:

Public Class frmVenues
    Public Structure VenueInfo
        Public venue_name As String
        Public venue_location As String
        Public venue_capacity As Integer
        Public venue_hirecost As Integer
    End Structure

    'Profile List of Venues
    Public Shared VenueInfos As New List(Of VenueInfo)()   'roster data

    Private Sub frmVenues_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        'read all infomations of wrestler from file. lines is profile array
        Dim lines() As String = IO.File.ReadAllLines("venues.txt")

        For Each line In lines
            'Parses the line string, make Venue Info and add it to Venue List
            'split string with ":"
            If line.Trim.Equals("") Then Continue For
            Dim strArr() = line.Split(":")

            'make Venue Info
            Dim vi As New VenueInfo()

            vi.venue_name = strArr(0)
            vi.venue_location = strArr(1)
            vi.venue_capacity = strArr(2)
            vi.venue_hirecost = strArr(3)

            'add Venue Info to Venue List
            VenueInfos.Add(vi)
        Next
        ComboBox1.SelectedIndex = 0
    End Sub

    Private Sub FillDataGridView(mode As Integer)
        DataGridView1bnb.Rows.Clear()
        For Each vi In VenueInfos
            Dim row As String() = New String() {vi.venue_name}
            DataGridView1bnb.Rows.Add(row)
        Next
    End Sub
End Class

0 个答案:

没有答案