Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In with Facebook Sign In with Google Sign In with OpenID

Categories

We have migrated to a new platform! Please note that you will need to reset your password to log in (your credentials are still in-tact though). Please contact lee@programmersheaven.com if you have questions.
Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Need help changing the color of background

ykim87ykim87 Posts: 4Member
When a button is clicked, it will change the color of the background of the control. Can anyone help a beginner to actual do this?

Thanks-Young

Comments

  • DaiMitnickDaiMitnick Posts: 77Member
    The background of the button or the form? Well here's both:

    [code]
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Button1.BackColor = Color.DarkSalmon
    Me.BackColor = Color.Aquamarine
    End Sub
    [/code]

    So if you create a button called Button1, this code will change the button's colour to DarkSalmon and the form itself to Aquamarine, just play around and edit as necessary. Beware though, if you have 3d-style buttons (the default), you will notice that the border and the edge just inside the border will not change colour, if you need to colour the whole button you can set it's "FlatStyle" property to "Flat" and use the code below in addition to changing the backcolour.

    [code]
    Button1.FlatAppearance.BorderColor = Color.DarkSalmon
    [/code]

    HTH, Dai



    ------------------------------------------
    Do or do not, there is no try. |
    ------------------------------------------
Sign In or Register to comment.