I have 22 labels. Half have DISCNumX
and the other half have TOTNumX
where X
is a number 1 through 10, respectively. I've stored the values that the label text needs to be updated to in a list. I've also stored the names of the labels in a list. I was trying to iterate through each list, since they share the same index, and update the label.text
to the value in the counts list.
Dim Counts As New List(Of Integer)
Dim DISCNumList As New List(Of Label)({NeedsCorrectionsDISCNum0, NotRecognizedDISCNum1, EPNErrorsDISCNum2, OptionHeadersDISCNum3, ProdPermsDISCNum4, ReadyToImportDISCNum5, WithMemosDISCNum6, RankWarningsDISCNum7, LifecycleWarningsDISCNum8})
Private Sub PopulateCounts()
Dim i As Integer = 0
InitializeComponent()
For Each cont As Control In TableLayoutPanel1.Controls
If cont.Name.Contains("DISCNum" & i.ToString) Then
DISCNumList(i).Text = Counts(i)
i += 1
End If
Next
End Sub
I've tried the above most recently, but I had been trying to do something as simple as this:
Private Sub PopulateCounts()
InitializeComponent()
For i = 0 To 10
DISCNumList(i).Text = Counts(i)
Next
End Sub
I would like to reiterate that the names of the labels in DISCNumList already exist on a form and I'm trying to update them. Any/all help here is greatly appreciated, as I have been able to get myself through a bunch of this stuff but am now properly stuck.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…