How to make a method for my code that changes the state, color and font of my buttons?

15 Views Asked by At

I want to make a method for this code. When I press a button, the color of the button changes to green and the other buttons changes to white. The font style for the press button changes to bold and the other buttons changes to regular. If it is already checked, I want the button to become white and with the font style regular. Any tips? I am fairly new to C# btw:D I want to make a

        private void check_Easy_CheckedChanged(object sender, EventArgs e)
        {
            if (check_Easy.Checked == true)
            {
                check_Easy.Font = new Font(check_Easy.Font, FontStyle.Bold);
                check_Middels.Font = new Font(check_Middels.Font, FontStyle.Regular);
                check_Hard.Font = new Font(check_Hard.Font, FontStyle.Regular);
                check_Custom.Font = new Font(check_Easy.Font, FontStyle.Regular);
                check_Easy.BackColor = Color.LawnGreen;
                check_Middels.BackColor = Color.White;
                check_Hard.BackColor = Color.White;
                check_Custom.BackColor = Color.White;
                check_Hard.Checked = false;
                check_Middels.Checked = false;
            }
            else
            {
                check_Easy.Font = new Font(check_Easy.Font, FontStyle.Regular);
                check_Easy.BackColor= Color.White;
            }
        }

        private void check_Middels_CheckedChanged(object sender, EventArgs e)
        {
            if (check_Middels.Checked == true)
            {
                check_Middels.Font = new Font(check_Middels.Font, FontStyle.Bold);
                check_Hard.Font = new Font(check_Hard.Font, FontStyle.Regular);
                check_Easy.Font = new Font(check_Easy.Font, FontStyle.Regular);
                check_Custom.Font = new Font(check_Easy.Font, FontStyle.Regular);
                check_Middels.BackColor = Color.LawnGreen;
                check_Easy.BackColor = Color.White;
                check_Hard.BackColor = Color.White;
                check_Custom.BackColor = Color.White;
                check_Easy.Checked = false;
                check_Hard.Checked = false;
            }
            else
            {
                check_Middels.Font = new Font(check_Middels.Font, FontStyle.Regular);
                check_Middels.BackColor= Color.White;
            }
        }

        private void check_Hard_CheckedChanged(object sender, EventArgs e)
        {
            if (check_Hard.Checked == true)
            {
                check_Hard.Font = new Font(check_Hard.Font, FontStyle.Bold);
                check_Middels.Font = new Font(check_Middels.Font, FontStyle.Regular);
                check_Easy.Font = new Font(check_Easy.Font, FontStyle.Regular);
                check_Custom.Font = new Font(check_Easy.Font, FontStyle.Regular);
                check_Hard.BackColor = Color.LawnGreen;
                check_Easy.BackColor = Color.White;
                check_Middels.BackColor = Color.White;
                check_Custom.BackColor = Color.White;
                check_Easy.Checked = false;
                check_Middels.Checked = false;
                check_Custom.Checked = false;
            }
            else
            {
                check_Hard.Font = new Font(check_Hard.Font, FontStyle.Regular);
                check_Hard.BackColor = Color.White;
            }
        }
        private void check_Custom_CheckedChanged(object sender, EventArgs e)
        {
         
            if (check_Custom.Checked == true)
            {
                check_Custom.Font = new Font(check_Hard.Font, FontStyle.Bold);
                check_Hard.Font = new Font(check_Hard.Font, FontStyle.Regular);
                check_Middels.Font = new Font(check_Middels.Font, FontStyle.Regular);
                check_Easy.Font = new Font(check_Easy.Font, FontStyle.Regular);
                check_Custom.BackColor = Color.LawnGreen;
                check_Hard.BackColor = Color.White;
                check_Easy.BackColor = Color.White;
                check_Middels.BackColor = Color.White;
                check_Easy.Checked = false;
                check_Middels.Checked = false;
                check_Hard.Checked = false;
            }
            else
            {
                check_Custom.Font = new Font(check_Hard.Font, FontStyle.Regular);
                check_Custom.BackColor = Color.White;
            }

I have started making a method, but I can't get it to work.

0

There are 0 best solutions below