locked
Colour Change RRS feed

  • Question

  • wnen i click button_1, i want form1's background-colour to change from Tan to orange, how would i go about this?
    Monday, November 7, 2005 6:08 PM

Answers




  • Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    me.backcolor = MyOrangeColor


    End
    Sub



     


    Now you could do a toggle of the colors like this



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim Static MyBool as boolean = True

    If MyBool then
        MyBool = False
        me.backcolor = MyOrangeColor
    else
        myBool = True
        me.BackColor = MyTanColor
    End
    Sub


     
    Monday, November 7, 2005 6:23 PM
  • yes....those are made up variables


    Dim MyOrangeColor as Color = Color.Orange

    Dim MyTanColor as Color = Color.Tan
    Monday, November 7, 2005 6:36 PM

All replies




  • Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    me.backcolor = MyOrangeColor


    End
    Sub



     


    Now you could do a toggle of the colors like this



    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

    Dim Static MyBool as boolean = True

    If MyBool then
        MyBool = False
        me.backcolor = MyOrangeColor
    else
        myBool = True
        me.BackColor = MyTanColor
    End
    Sub


     
    Monday, November 7, 2005 6:23 PM
  • Exellent:) Although i got 1 error, it says it 'myorangecolor is not declared', any ideas why?
    Monday, November 7, 2005 6:32 PM
  • yes....those are made up variables


    Dim MyOrangeColor as Color = Color.Orange

    Dim MyTanColor as Color = Color.Tan
    Monday, November 7, 2005 6:36 PM
  • Is it possible 2 do the same for a group-box as well?
    Monday, November 7, 2005 7:49 PM
  • yes


    check properties of groupbox
    Monday, November 7, 2005 8:59 PM