The code provided will solve the problem of every time changing the properties of controls like fore color, background etc.Basically we encounter a problem like every time we have to go to the properties and change the properties for color whenever we design a new form. this code easily solves the above encountered situation.
We had encountered this problem when ever we had to design several number of forms.
Using the code
What you need to do is just copy paste the code whenever you came through this situation and you will see that you will see that forms background and forecolor will change at runtime dynamically with inserting a single word on it.
//<code> written in vb.net
// Public Sub disp(ByVal a As Control)
a.ForeColor = Color.FromKnownColor(KnownColor.ControlText)
a.BackColor = Color.FromKnownColor(KnownColor.Control)
For Each ctrl As Control In a.Controls
If TypeOf ctrl Is Panel Then
If TypeOf ctrl Is Button Then
CType(ctrl, Button).FlatStyle = FlatStyle.Flat
CType(ctrl, Button).ImageAlign = ContentAlignment.MiddleLeft
ctrl.ForeColor = Color.FromKnownColor(KnownColor.ControlText)
ctrl.BackColor = Color.FromKnownColor(KnownColor.Control)
If TypeOf ctrl Is TextBox Or TypeOf ctrl Is ComboBox Then
ctrl.ForeColor = Color.FromKnownColor(KnownColor.WindowText)
ctrl.BackColor = Color.FromKnownColor(KnownColor.Window)
Points of Interest
This code can be utilised in any .net frame work environment you need