I am writing down a simple schedule planner app using WinForms in Visual Basic .NET, and I have this "Edit Preferences" where I would want the user to be able to change colors of all labels. I tried to use this code:
Public Sub darkMode(ByVal darkModeOn As Boolean)
If darkModeOn Then
For Each c As Control In Me.Controls
If c IsNot lblTitle Then
If TypeOf c Is Label Then DirectCast(c, Label).ForeColor = Color.FromArgb(255, 255, 255)
ElseIf TypeOf c Is Panel Then
For Each pnlPanel As Panel In Me.Controls.OfType(Of Panel)()
pnlPanel.BackColor = Color.FromArgb(66, 66, 66)
Next
End If
Next
End Sub
But when I run that code, it only changes the ForeColor of the Labels that are immediate children of the form and the changes does not apply to Labels that are inside other containers like Panels. Is there any way to change the ForeColor of all Labels, even those that are not immediate children of the Form?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)