can i chnge all button font color on every form that i hve create. .i just want to click 1 button and it show menu choose color..

Recommended Answers

All 6 Replies

Yes, You can change the buttons color on multiple forms just by clicking one button.
First, Create two forms or more and add one or more button(s) on form1 and form2 and soon.
Double click on start up form (form1) button. type the following code:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        Dim frm1 As New Form2
        Dim colr As New ColorDialog
        colr.ShowDialog()
        Button1.BackColor = colr.Color
        frm1.Button1.BackColor = colr.Color
        frm1.Show()
    End Sub

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

its work...but i wont to change oly text color on button...

thanz dude..i have just change backcolor to forecolor...

but...after i relaunch program...text fore color change to default color like black...how to save color after i pick it..

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
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.