- When any one of the color buttons is clicked, the background color of the label is to be set to the background color of the color button that was clicked AND the background of the form is to be set to the color the label started with before being changed. (This means the color to the form will be changing at Runtime
- As variables and object declarations have not been covered yet, do not try and use any variables when doing color switches. You will need to figure out how to switch colors and letters around using only the controls and various properties of those controls. Here is your hint on this: A control does not have to be visible for you to access the properties of the control.
When i click a color button on the left the back color to the label is supposed to turn that color and the current backColor of the label is supposed to switch to the backColor of the form. I have to do this without using variables. My thought was to create 18 different labels and set the visible properties to false until the button was clicked but windows forms transparency does not support transparency to other labels just to the form. I can only think of storing the colors as variables but that is not what the instructions say to do. Any guidance would be greatly appreciated.
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows.Forms; namespace WindowsFormsApplication2 { public partial class Form1 : Form { public Form1() { InitializeComponent(); Default_Label.Visible = true; Default_LabelX.Visible = true; } private void label1_Click(object sender, EventArgs e) { } private void button1_Click(object sender, EventArgs e) { Red_Label.Visible = true; Default_LabelX.Visible = false; Default_Label.Visible = false; orange_label.Visible = false; yellow_label.Visible = false; green_label.Visible = false; cyan_label.Visible = false; blue_label.Visible = false; fuchsia_label.Visible = false; spring_label.Visible = false; crimson_label.Visible = false; Default_LabelX.Visible = false; } private void button2_Click(object sender, EventArgs e) { Red_Label.Visible = false; Default_Label.Visible = false; orange_label.Visible = true; yellow_label.Visible = false; green_label.Visible = false; cyan_label.Visible = false; blue_label.Visible = false; fuchsia_label.Visible = false; spring_label.Visible = false; crimson_label.Visible = false; Default_LabelX.Visible = false; } private void button3_Click(object sender, EventArgs e) { Red_Label.Visible = false; Default_Label.Visible = false; orange_label.Visible = false; yellow_label.Visible = true; green_label.Visible = false; cyan_label.Visible = false; blue_label.Visible = false; fuchsia_label.Visible = false; spring_label.Visible = false; crimson_label.Visible = false; Default_LabelX.Visible = false; } private void button4_Click(object sender, EventArgs e) { Red_Label.Visible = false; Default_Label.Visible = false; orange_label.Visible = false; yellow_label.Visible = false; green_label.Visible = true; cyan_label.Visible = false; blue_label.Visible = false; fuchsia_label.Visible = false; spring_label.Visible = false; crimson_label.Visible = false; Default_LabelX.Visible = false; } private void button5_Click(object sender, EventArgs e) { Red_Label.Visible = false; Default_Label.Visible = false; orange_label.Visible = false; yellow_label.Visible = false; green_label.Visible = false; cyan_label.Visible = true; blue_label.Visible = false; fuchsia_label.Visible = false; spring_label.Visible = false; crimson_label.Visible = false; Default_LabelX.Visible = false; } private void button6_Click(object sender, EventArgs e) { Red_Label.Visible = false; Default_Label.Visible = false; orange_label.Visible = false; yellow_label.Visible = false; green_label.Visible = false; cyan_label.Visible = false; blue_label.Visible = true; fuchsia_label.Visible = false; spring_label.Visible = false; crimson_label.Visible = false; Default_LabelX.Visible = false; } private void button7_Click(object sender, EventArgs e) { Red_Label.Visible = false; Default_Label.Visible = false; orange_label.Visible = false; yellow_label.Visible = false; green_label.Visible = false; cyan_label.Visible = false; blue_label.Visible = false; fuchsia_label.Visible = true; spring_label.Visible = false; crimson_label.Visible = false; Default_LabelX.Visible = false; } private void button8_Click(object sender, EventArgs e) { Red_Label.Visible = false; Default_Label.Visible = false; orange_label.Visible = false; yellow_label.Visible = false; green_label.Visible = false; cyan_label.Visible = false; blue_label.Visible = false; fuchsia_label.Visible = false; spring_label.Visible = true; crimson_label.Visible = false; Default_LabelX.Visible = false; } private void button9_Click(object sender, EventArgs e) { Red_Label.Visible = false; Default_Label.Visible = false; orange_label.Visible = false; yellow_label.Visible = false; green_label.Visible = false; cyan_label.Visible = false; blue_label.Visible = false; fuchsia_label.Visible = false; spring_label.Visible = false; crimson_label.Visible = true; Default_LabelX.Visible = false; } private void button6_ControlAdded(object sender, ControlEventArgs e) { } private void button6_BackColorChanged(object sender, EventArgs e) { } private void button14_Click(object sender, EventArgs e) { Label_Y.Visible = false; Label_D.Visible = false; label_G.Visible = false; label_H.Visible = false; label_I.Visible = false; label_J.Visible = false; label_P.Visible = false; label_R.Visible = true; label_T.Visible = false; Default_LabelX.Visible = false; } private void buttonY_Click(object sender, EventArgs e) { Label_Y.Visible = true; Label_D.Visible = false; label_G.Visible = false; label_H.Visible = false; label_I.Visible = false; label_J.Visible = false; label_P.Visible = false; label_R.Visible = false; label_T.Visible = false; Default_LabelX.Visible = false; } private void buttonD_Click(object sender, EventArgs e) { Label_Y.Visible = false; Label_D.Visible = true; label_G.Visible = false; label_H.Visible = false; label_I.Visible = false; label_J.Visible = false; label_P.Visible = false; label_R.Visible = false; label_T.Visible = false; Default_LabelX.Visible = false; } private void buttonP_Click(object sender, EventArgs e) { Label_Y.Visible = false; Label_D.Visible = false; label_G.Visible = false; label_H.Visible = false; label_I.Visible = false; label_J.Visible = false; label_P.Visible = true; label_R.Visible = false; label_T.Visible = false; Default_LabelX.Visible = false; } private void buttonH_Click(object sender, EventArgs e) { Label_Y.Visible = false; Label_D.Visible = false; label_G.Visible = false; label_H.Visible = true; label_I.Visible = false; label_J.Visible = false; label_P.Visible = false; label_R.Visible = false; label_T.Visible = false; Default_LabelX.Visible = false; } private void buttonT_Click(object sender, EventArgs e) { Label_Y.Visible = false; Label_D.Visible = false; label_G.Visible = false; label_H.Visible = false; label_I.Visible = false; label_J.Visible = false; label_P.Visible = false; label_R.Visible = false; label_T.Visible = true; Default_LabelX.Visible = false; } private void buttonG_Click(object sender, EventArgs e) { Label_Y.Visible = false; Label_D.Visible = false; label_G.Visible = true; label_H.Visible = false; label_I.Visible = false; label_J.Visible = false; label_P.Visible = false; label_R.Visible = false; label_T.Visible = false; Default_LabelX.Visible = false; } private void button15_Click(object sender, EventArgs e) { Label_Y.Visible = false; Label_D.Visible = false; label_G.Visible = false; label_H.Visible = false; label_I.Visible = false; label_J.Visible = true; label_P.Visible = false; label_R.Visible = false; label_T.Visible = false; Default_LabelX.Visible = false; } private void button18_Click(object sender, EventArgs e) { Label_Y.Visible = false; Label_D.Visible = false; label_G.Visible = false; label_H.Visible = false; label_I.Visible = true; label_J.Visible = false; label_P.Visible = false; label_R.Visible = false; label_T.Visible = false; Default_LabelX.Visible = false; } private void cyan_label_Click(object sender, EventArgs e) { } } }
Last edited: