Also, see if this helps.
Dim myCoolColorDialog As New ColorDialog '// your Color Dialog.
If myCoolColorDialog.ShowDialog = DialogResult.OK Then '// check if OK clicked.
For Each ctl As Control In Me.Controls '// loop thru all controls on Form, if on another Form, use " In Form2.Controls", etc..
If TypeOf ctl Is Button Then ctl.BackColor = myCoolColorDialog.Color '// locate Button and change BackColor.
Next
End If
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384
See if this helps about saving and loading a color to/from a file.
Public Class Form1
Private myFile As String = "C:\test" '// File used to Save/Load Color.
Private mySelectedCoolColor As New Color '// stores loaded color from File or ColorDialog.
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
IO.File.WriteAllText(myFile, mySelectedCoolColor.ToArgb.ToString) '// save Color to file as ARGB Color.
End Sub
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If IO.File.Exists(myFile) Then '// check if file exists.
mySelectedCoolColor = Color.FromArgb(CInt(IO.File.ReadAllText(myFile))) '// read ARGB Color and set it.
myCoolThemeColorSub(mySelectedCoolColor) '// send the Color to your Theme Sub.
End If
Me.Show()
Dim myCoolColorDialog As New ColorDialog '// your Color Dialog.
If myCoolColorDialog.ShowDialog = DialogResult.OK Then '// check if OK clicked.
mySelectedCoolColor = myCoolColorDialog.Color '// store the color to use for when saving.
myCoolThemeColorSub(mySelectedCoolColor) '// send the Color to your Theme Sub.
End If
End Sub
Private Sub myCoolThemeColorSub(ByVal myCoolColorToUse As Color)
For Each ctl As Control In Me.Controls '// loop thru all controls on Form.
If TypeOf ctl Is Button Then ctl.ForeColor = myCoolColorToUse '// locate Button and change Color.
Next
End Sub
End Class
codeorder
Posting Virtuoso
1,913 posts since Aug 2010
Reputation Points: 255
Solved Threads: 384