Bei VB6 konnte in Abh. vom Anwender die Anzahl der Controls ( z.B. FlexGrid ) beim Programmstart
abgefragt und mit
for i=1 to WunschZahl
Load Control1(i)
next
erzeugt werden.
Wenn die Wunschzahl max 40 sein kann, muß ich ich bei VB.net jetzt z.B. vorsorglich folgendes machen:
Dim ca As New ArrayList()
Friend WithEvents txBox1 As System.Windows.Forms.TextBox
Friend WithEvents txBox2 As System.Windows.Forms.TextBox
... bis
Friend WithEvents txBox40 As System.Windows.Forms.TextBox
und anschließend jeweils
Me.txBox1 = New System.Windows.Forms.TextBox()
Me.txBox1.Text = ""
Controls.Add(txBox1)
ca.Add(txBox1)
.... bis
Me.txBox40 = New System.Windows.Forms.TextBox()
Me.txBox40.Text = ""
ca.Add(txBox40)
Controls.Add(txBox40)
Wenn Wunschzahl < 40, dann Controls.remove.
Oder gibt es da eine einfache, elegante Lösung?
abgefragt und mit
for i=1 to WunschZahl
Load Control1(i)
next
erzeugt werden.
Wenn die Wunschzahl max 40 sein kann, muß ich ich bei VB.net jetzt z.B. vorsorglich folgendes machen:
Dim ca As New ArrayList()
Friend WithEvents txBox1 As System.Windows.Forms.TextBox
Friend WithEvents txBox2 As System.Windows.Forms.TextBox
... bis
Friend WithEvents txBox40 As System.Windows.Forms.TextBox
und anschließend jeweils
Me.txBox1 = New System.Windows.Forms.TextBox()
Me.txBox1.Text = ""
Controls.Add(txBox1)
ca.Add(txBox1)
.... bis
Me.txBox40 = New System.Windows.Forms.TextBox()
Me.txBox40.Text = ""
ca.Add(txBox40)
Controls.Add(txBox40)
Wenn Wunschzahl < 40, dann Controls.remove.
Oder gibt es da eine einfache, elegante Lösung?
Comment