Advertisement
foozar

PanelColor

Oct 23rd, 2019
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.32 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.Linq;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10.  
  11. namespace testColor
  12. {
  13.     public partial class Form1 : Form
  14.     {
  15.         public Form1()
  16.         {
  17.             InitializeComponent();
  18.             comboBox1.DropDownStyle = ComboBoxStyle.DropDownList;
  19.             comboBox1.SelectedIndex = 0;
  20.         }
  21.         private void Form1_Load(object sender, EventArgs e)
  22.         {
  23.            
  24.         }
  25.         private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
  26.         {
  27.            
  28.  
  29.             switch (comboBox1.SelectedItem.ToString())
  30.             {
  31.                 case "Black":
  32.                     panel1.BackColor = Color.Black;
  33.                     break;
  34.                 case "Red":
  35.                     panel1.BackColor = Color.Red;
  36.                     break;
  37.                 case "Green":
  38.                     panel1.BackColor = Color.Green;
  39.                     break;
  40.                 case "Blue":
  41.                     panel1.BackColor = Color.Blue;
  42.                     break;
  43.                 case "White":
  44.                     panel1.BackColor = Color.White;
  45.                     break;
  46.  
  47.             }
  48.  
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement