Ich kann nirgendwo eine Antwort finden. Ich definiere eine neue Instanz einer Formularsteuerungssammlung, aber zur Laufzeit ist die Sammlung leer. Es funktioniert für eine Ladeschaltfläche im Formular, aber nicht für eine andere. Der Code ist genau derselbe, aber einer funktioniert, der andere nicht. Hier ist der relevante Code:Empty ControlCollection zur Laufzeit
Private Sub miFLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miFLoad.Click
Dim FilePath As String = "C:\FList\FList.flt"
Dim LoadFile As New SaveandLoad.SaveAndLoad
Dim FileRead As New Simple3Des("MyPassword")
Dim FileString As String = FileRead.ReadFile(FilePath)
With LoadFile
.WhichList = dgFList
.FilePath = FilePath
.DecryptedString = FileRead.DecryptData(FileString)
End With
Call LoadFile.LoadFile()
End Sub
Diese Last-Taste nicht
Private Sub miCLoad_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles miCLoad.Click
Dim FilePath As String = "C:\FList\CList.clt"
Dim LoadFile As New SaveandLoad.SaveAndLoad
Dim FileRead As New Simple3Des("MyPassword")
Dim FileString As String = FileRead.ReadFile(FilePath)
With LoadFile
.WhichList = dgCourses
.FilePath = FilePath
.DecryptedString = FileRead.DecryptData(FileString)
End With
Call LoadFile.LoadFile()
End Sub
Dieser ist geladen.
Public Sub LoadFile()
Dim dgRow As DataGridViewRow
Dim dgCell As DataGridViewTextBoxCell
Dim Lines() As String = DecryptedString.Split(vbLf)
Dim LinesList As List(Of String) = Lines.ToList
LinesList.RemoveAt(Lines.Length - 1)
For Each Line As String In LinesList
Dim Fields() As String = Line.Split(",")
dgRow = New DataGridViewRow
For x = 0 To (WhichList.Columns.Count - 1) Step 1
dgCell = New DataGridViewTextBoxCell
dgCell.Value = Fields(x).ToString
dgRow.Cells.Add(dgCell)
Next
WhichList.Rows.Add(dgRow)
Next
Dim FormControls As New frmFacultyList.ControlCollection(frmFacultyList)
For Each DGV As DataGridView In FormControls
If WhichList.Name = DGV.Name Then
DGV = WhichList
DGV.Refresh()
End If
Next
End Sub
Hier geben sie die Informationen an. Auch hier ist die FormControls-Variable leer für den Klick auf FLoad-Schaltfläche, nicht jedoch für Klick auf CLoad-Schaltfläche. Jede Hilfe wäre willkommen.
Edit: Sorry, hier sind die relevant Public Properties
Public Property WhichList As New DataGridView
Public Property FilePath As String
Public Property DecryptedString As String
Public Property EncryptedString As String