Я создал список (Of GroupBox) (), который был создан во время выполнения. Каждая группа имеет метки и текстовые поля. Мне нужно периодически обновлять значения в текстовых полях каждого группового окна. Мне нужен доступ к TxtCool; TxtHeat; и TxtActualTemp (ближе к концу моего кода) Как я могу получить доступ к текстовому полю каждого из моих текстовых полей в каждом групповом окне после их создания?
For j As Integer = 0 To Thermostats.Count - 1
Dim ThermostatName As String
Dim Model As String
Dim IPAddress As String
With Thermostats(j)
ThermostatName = .ThermostatName
Model = .Model
IPAddress = .IPAddress
End With
Dim GrpBox As New GroupBox() With {
.Location = New Point(265, 27),
.Size = New Size(253, 176),
.Text = ThermostatName,
.BackColor = Color.White,
.FlatStyle = BorderStyle.Fixed3D,
.BackgroundImage = Imagelist1.Images(0),
.Margin = New Padding(20, 30, 0, -10)
}
GrpBox.Controls.Add(New Label() With {
.Location = New Point(146, 65),
.AutoSize = True,
.Text = "Heat To",
.Font = New Font(FontFamily.GenericSansSerif, 8, FontStyle.Regular),
.Visible = True
})
GrpBox.Controls.Add(New Label() With {
.Location = New Point(210, 80),
.AutoSize = True,
.Text = TempUnit,
.Font = New Font(FontFamily.GenericSansSerif, 12, FontStyle.Bold),
.Visible = True
})
GrpBox.Controls.Add(New Label() With {
.Location = New Point(146, 110),
.AutoSize = True,
.Text = "Cool To",
.Font = New Font(FontFamily.GenericSansSerif, 8, FontStyle.Regular),
.Visible = True
})
GrpBox.Controls.Add(New Label() With {
.Location = New Point(210, 125),
.AutoSize = True,
.Text = TempUnit,
.Font = New Font(FontFamily.GenericSansSerif, 12, FontStyle.Bold),
.Visible = True
})
GrpBox.Controls.Add(New Label() With {
.Location = New Point(15, 66),
.Size = New Size(125, 15),
.Text = "Current Temperature",
.Font = New Font(FontFamily.GenericSansSerif, 8, FontStyle.Regular),
.Visible = True
})
GrpBox.Controls.Add(New Label() With {
.Location = New Point(90, 80),
.AutoSize = True,
.Text = TempUnit,
.Font = New Font(FontFamily.GenericSansSerif, 24, FontStyle.Bold),
.Visible = True
})
GrpBox.Controls.Add(New Label() With {
.Location = New Point(20, 20),
.AutoSize = True,
.Text = Model,
.Font = New Font(FontFamily.GenericSansSerif, 8, FontStyle.Regular),
.Visible = True
})
Dim TxtCool As New TextBox() With {
.Location = New Point(150, 125),
.Size = New Drawing.Size(60, 25),
.Visible = True,
.Enabled = False,
.BackColor = Color.White,
.ForeColor = Color.Black,
.BorderStyle = BorderStyle.FixedSingle,
.Font = New Font(FontFamily.GenericSansSerif, 12, FontStyle.Bold),
.Text = 23.0
}
GrpBox.Controls.Add(TxtCool)
Dim TxtHeat As New TextBox() With {
.Location = New Point(150, 80),
.Size = New Size(60, 25),
.Visible = True,
.Enabled = False,
.BackColor = Color.White,
.ForeColor = Color.Black,
.BorderStyle = BorderStyle.FixedSingle,
.Font = New Font(FontFamily.GenericSansSerif, 12, FontStyle.Bold),
.Text = 20.5
}
GrpBox.Controls.Add(TxtHeat)
Dim TxtActualTemp As New TextBox With {
.Location = New Point(19, 82),
.Size = New Drawing.Size(75, 45),
.Visible = True,
.Enabled = False,
.BackColor = Color.White,
.ForeColor = Color.Black,
.BorderStyle = BorderStyle.FixedSingle,
.Font = New Font(FontFamily.GenericSansSerif, 24, FontStyle.Bold),
.Text = (6 * Rnd() + 19)
}
GrpBox.Controls.Add(TxtActualTemp)
GrpBoxes.Add(GrpBox)
Me.TblLytPnl.Controls.Add(GrpBox)
Next