SHARE
TWEET

Combobox update text

capasha Mar 4th, 2014 218 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         public Form1()
  2.         {
  3.             InitializeComponent();
  4.             this.comboBox1.Items.Add("test0: on");
  5.             this.comboBox1.Items.Add("test1: on");
  6.             this.comboBox1.Items.Add("god: on");
  7.             this.comboBox1.Items.Add("test2: on");
  8.             this.comboBox1.Items.Add("test3: on");
  9.         }
  10.  
  11.         private void button1_Click(object sender, EventArgs e)
  12.         {
  13.            
  14.  
  15.                 for (int i = 0; i < this.comboBox1.Items.Count; i++)
  16.                 {
  17.                     if (this.comboBox1.Items[i].ToString() == "god: on")
  18.                     {
  19.                         this.comboBox1.Items.RemoveAt(i);
  20.                         this.comboBox1.Items.Insert(i, "god: off");
  21.                     }
  22.                     else if (this.comboBox1.Items[i].ToString() == "god: off")
  23.                     {
  24.                         this.comboBox1.Items.RemoveAt(i);
  25.                         this.comboBox1.Items.Insert(i, "god: on");
  26.                     }
  27.                 }
  28.         }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top