ユーザーがリストにテーブルを追加できるようにするプログラムを作成しています。しかし、リストをlistBoxに表示するのに問題があります
テーブルとそのプロパティは、クラスの元のリストに問題なく追加されますが、表示しようとすると、データがなくなったようです。リストに何か問題があると思いますが、何が原因かわかりません。リストを別の配列リストに入れてみましたが、結果はありません。
Imports Table_Tracker_Library
Public Class Main_Form
Private Property _Table As New Table
Private Property _ShowList As Table()
Private Sub Btn_Add_Table_Click(sender As Object, e As EventArgs) Handles Btn_Add_Table.Click
Form_Create_Button.Show()
End Sub
Public Sub Renew()
_ShowList = _Table.GetList()
Me.LB_ActiveTables.ClearSelected()
For Each table As Table In _ShowList
LB_ActiveTables.Items.Add("Table #" & table.Number)
Next
LB_ActiveTables.Refresh()
End Sub
'Private Function GetList() As Table()
' Dim TempList As New List(Of Table)
' For Each table As Table In _Table.ListOfTable
' TempList.Add(table)
' Next
' Return TempList.ToArray
'End Function
End Class
-
Imports Table_Tracker_Library
Public Class Form_Create_Button
Private Property _Table As New Table
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles btn_addtable.Click
_Table.CreateTable(Me.txb_TableNr.Text, Me.txb_PplNr.Text)
Main_Form.Renew()
Me.Close()
End Sub
Private Sub Button2_Click(sender As Object, e As EventArgs) Handles btn_discard.Click
Me.Close()
End Sub
End Class
-
Public Class Table
Public Property Number As Int32
Public Property NumberOfPeople As Int32
Public Property ListOfTable As New List(Of Table)
Public Sub CreateTable(TableNrString As String, PersonNrString As String)
Dim TableNR As Int32 = CInt(TableNrString)
Dim PersonNr As Int32 = CInt(PersonNrString)
Dim NewTable As New Table With {.Number = TableNR, .NumberOfPeople = PersonNr}
AddTable(NewTable)
End Sub
Private Sub AddTable(Table As Table)
ListOfTable.Add(Table)
End Sub
Public Function GetList() As Table()
Dim TempList As New List(Of Table)
For Each table As Table In ListOfTable
TempList.Add(table)
Next
Return TempList.ToArray
End Function
End Class