We're a community of 1077K IT Pros here for help, advice, solutions, professional growth and fun. Join us!
1,076,248 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Start New Discussion Reply to this Discussion

font color changer

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..

3
Contributors
6
Replies
2 Days
Discussion Span
2 Years Ago
Last Updated
7
Views
Question
Answered
arezz09
Junior Poster
101 posts since Feb 2011
Reputation Points: 8
Solved Threads: 2
Skill Endorsements: 0

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
geoamins2
Light Poster
27 posts since Feb 2011
Reputation Points: 12
Solved Threads: 2
Skill Endorsements: 0

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
Postaholic
2,124 posts since Aug 2010
Reputation Points: 256
Solved Threads: 387
Skill Endorsements: 8

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

arezz09
Junior Poster
101 posts since Feb 2011
Reputation Points: 8
Solved Threads: 2
Skill Endorsements: 0

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

arezz09
Junior Poster
101 posts since Feb 2011
Reputation Points: 8
Solved Threads: 2
Skill Endorsements: 0

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

arezz09
Junior Poster
101 posts since Feb 2011
Reputation Points: 8
Solved Threads: 2
Skill Endorsements: 0

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
Postaholic
2,124 posts since Aug 2010
Reputation Points: 256
Solved Threads: 387
Skill Endorsements: 8
Question Answered as of 2 Years Ago by codeorder and geoamins2

This question has already been solved: Start a new discussion instead

Post: Markdown Syntax: Formatting Help
 
You
View similar articles that have also been tagged:
 
© 2013 DaniWeb® LLC
Page rendered in 0.0984 seconds using 2.72MB