Hello friends now I am going to write my first articles.
Here I m trying to explain, how to change the whole project theme by just changing the main theme file in VB.NET project.
What this code actually does is that it visit all the windows form control on the form and set the properties of the control so if you have 100 forms and want to change the GUI or color of the button or anything else you can by changing in only one file.
Here is the code.
Public Class colour
Public Shared Sub colordesign(ByRef formc As Form)
formc.BackColor = Color.WhiteSmoke
Dim ct As Control = formc.GetNextControl(formc, True) 'This will take the first control from the form
Do Until ct Is Nothing
If TypeOf ctl Is GroupBox Then 'This will set the settings for all groupbox in form
ct.BackColor = Color.Silver 'This will change the color of all the group box.
Dim myfont As System.Drawing.Font
myfont = New System.Drawing.Font("Microsoft Sans Serif", 9, FontStyle.Bold, GraphicsUnit.Point)
ctl.Font = myfont 'You can set the font
ctl.ForeColor = Color.Black
End If
'If TypeOf ctl Is Label Then 'This will set the all settings for the Label.
' Dim myfont As System.Drawing.Font
' myfont = New System.Drawing.Font("Microsoft Sans Serif", FontStyle.Bold, GraphicsUnit.Point)
' ctl.ForeColor = Color.Black
'End If
If TypeOf ctl Is Button Then
ctl.BackColor = Color.Gray
ctl.ForeColor = Color.Snow
Dim myfont As System.Drawing.Font
myfont = New System.Drawing.Font("Arial", 12, FontStyle.Bold)
ctl.Font = myfont
ctl.Height = 29
End If
ctl = formx.GetNextControl(ctl, True) 'after checking the first control take the next control in the form.
Loop
End Sub
End Class
Now you can customize with any number of windows form which are basically used in all the forms and set all the properties from the class file.
Hope you all like this article.