If the RGB color is (64, 64, 255), change it to (64, 255, 64).

This is a discussion on If the RGB color is (64, 64, 255), change it to (64, 255, 64). within the C# Programming forums, part of the General Programming Boards category; Hi, there. Does anybody know how to check if the color is " 64, 64, 255" and then change it ...

  1. #1
    Registered User Grayson_Peddie's Avatar
    Join Date
    May 2002
    Posts
    96

    Question Checking the color and changing the color

    Hi, there. Does anybody know how to check if the color is " 64, 64, 255" and then change it to my preferred color? Let's say that when I run a program and I press a button to change all the colors, all the colors that were specified in the code will be executed and all the colors will changed. Here's the code that don't work:

    Code:
            private void Color_Switcher_Click(object sender, System.EventArgs e)
            {
                if(BackColor = Color.FromArgb( 64,  64, 255))
                {
                    BackColor = Color.FromArgb( 64, 255,  64);
                    TimedEvents.BackColor =
                                Color.FromArgh(128, 255, 128);
                    NonTimedEvents.BackColor =
                                Color.FromArgb(128, 255, 128);
                    Color_Switcher.BackColor =
                                Color.FromArgb( 64, 255,  64);
                    Color_Switcher.Text = "Change too blue!" ;
                    GoodBye.BackColor =
                                Color.FromArgb( 64, 255,  64);
                    Shrink.BackColor =
                                Color.FromArgb( 64, 255,  64);
                }
                else 
                {
                    BackColor = Color.FromArgb( 64,  64, 255);
                    TimedEvents.BackColor =
                                Color.FromArgh(128, 128, 255);
                    NonTimedEvents.BackColor =
                                Color.FromArgb(128, 128, 255);
                    Color_Switcher.BackColor =
                                Color.FromArgb( 64,  64, 255);
                    Color_Switcher.Text = "Change too blue!" ;
                    GoodBye.BackColor =
                                Color.FromArgb( 64,  64, 255);
                    Shrink.BackColor =
                                Color.FromArgb( 64,  64, 255);
                }
            }
    Can anybody please help with the if statement? This is the code for telling the program if the color is "64,64,255" or "64,255,64".

    Thank you!
    -Grayson
    Last edited by Grayson_Peddie; 06-14-2003 at 11:29 AM.
    View in Braille.
    http://www.future-gpnet.com/braille.jpg

    Like a bolt out of the BLUE,
    Fate steps up and sees you THROUGH,
    When you wish upon a STAR
    YOUR DREAMS COME TRUE.

  2. #2
    the hat of redundancy hat nvoigt's Avatar
    Join Date
    Aug 2001
    Location
    Hannover, Germany
    Posts
    3,139
    if( BackColor = Color.FromArgb( 64, 64, 255) )
    Put a == in there
    hth
    -nv

    She was so Blonde, she spent 20 minutes looking at the orange juice can because it said "Concentrate."

    When in doubt, read the FAQ.
    Then ask a smart question.

  3. #3
    Registered User Grayson_Peddie's Avatar
    Join Date
    May 2002
    Posts
    96

    Talking Yes!!

    NVoigt, thank you for your help! I didn't realize that the BackColor can support conditional statements. Thanks again!

    -Grayson

    PS: Wh en I started learning C++/C#, I know how to use "==" for the if and else if statement.
    View in Braille.
    http://www.future-gpnet.com/braille.jpg

    Like a bolt out of the BLUE,
    Fate steps up and sees you THROUGH,
    When you wish upon a STAR
    YOUR DREAMS COME TRUE.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Dynamically allocating 3D array
    By ssharish2005 in forum C Programming
    Replies: 8
    Last Post: 02-26-2008, 03:07 PM
  2. File IO
    By Jack1982 in forum C++ Programming
    Replies: 9
    Last Post: 10-15-2007, 01:14 AM
  3. strange number problem
    By kkjj in forum C Programming
    Replies: 9
    Last Post: 08-09-2007, 07:30 AM
  4. Stopwatch program (need help!)
    By modnar in forum C Programming
    Replies: 9
    Last Post: 03-21-2004, 11:42 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21