private void EffectSeletor_SelectedIndexChanged(object sender, EventArgs e) { SetColorButton.Enabled = true; // Since a setting changed, make the apply button functional again switch (EffectSelector.SelectedItem as string) { case "Breathing": ColorSelector2.Show(); break; // If the user selected Breathing then they are allowed to choose a second color default: ColorSelector2.Hide(); break; } }
public Form1() { InitializeComponent(); // Adds an object from the MyColor class which contains a string for the ComboBox and // a ColoreColor object to easily set things later based on the user's selection ColorSelector.Items.Add(new MyColor(ColoreColor.Red, "Red")); ColorSelector.Items.Add(new MyColor(ColoreColor.Green, "Green")); ColorSelector.Items.Add(new MyColor(ColoreColor.Blue, "Blue")); ColorSelector.Items.Add(new MyColor(new ColoreColor(0, 0, 0), "None")); ColorSelector.SelectedIndex = 0; // Copy the previous Items into the second ComboBox object[] oContainer = new object[ColorSelector.Items.Count]; ColorSelector.Items.CopyTo(oContainer, 0); ColorSelector2.Items.AddRange(oContainer); ColorSelector2.SelectedIndex = 0; // Name the strings for each device and store them into a ComboBox InstanceSelector.Items.Add("All"); InstanceSelector.Items.Add("Mouse"); InstanceSelector.Items.Add("Keyboard"); InstanceSelector.Items.Add("Keypad"); InstanceSelector.Items.Add("Mousepad"); InstanceSelector.Items.Add("Headset"); InstanceSelector.SelectedIndex = 0; // Name the strings for each effect and store them into a ComboBox EffectSelector.Items.Add("Static"); EffectSelector.Items.Add("Breathing"); EffectSelector.Items.Add("Wave"); EffectSelector.Items.Add("Reactive"); EffectSelector.SelectedIndex = 0; // Hide the second color since it can only be used with certain effects ColorSelector2.Hide(); }