Muhammad Ahsan

Muhammad Ahsan

  • NA
  • 265
  • 6.9k

Remove the item from ComboBox once it's been selected in the previous

Jan 5 2021 6:04 PM
I'm lost here, I wanna remove the item from ComboBox once it's been selected in the previous ComboBox. I have tried many approaches but didn't resolve this problem. Please help me in solving this problem and below I've included all of the code. Any tips would be greatly appreciated!
 
  1. ComboBox[] combo_for_constraint = new ComboBox[count];  
  2.                 int combo_for_constraint_x = 250, combo_for_constraint_y = 50;  
  3.                 for (int i = 1; i < count; i++)  
  4.                 {  
  5.                     combo_for_constraint[i] = new ComboBox();  
  6.                     combo_for_constraint[i].Location = new System.Drawing.Point(combo_for_constraint_x,  
  7.  combo_for_constraint_y + (i * 10));  
  8.                     combo_for_constraint[i].Size = new Size(100, 50);  
  9.                     combo_for_constraint[i].Name = "combo_for_constraintbx" + i.ToString();  
  10.                     combo_for_constraint[i].DropDownStyle = ComboBoxStyle.DropDownList;  
  11.                     tabPage2.Controls.Add(combo_for_constraint[i]);  
  12.                     tabPage2.ResumeLayout(false);  
  13.                     combo_for_constraint_y += 40;  
  14.                     tabPage2.Refresh();  
  15.                     if (i >= 2 && combo_for_constraint[i - 1].Text == "PRIMARY KEY")  
  16.                     {  
  17.                         combo_for_constraint[i + 1].Items.RemoveAt(1);  
  18.                     }  
  19.                     else  
  20.                     {  
  21.                         combo_for_constraint[i].Items.Add("UNIQUE");  
  22.                         combo_for_constraint[i].Items.Add("PRIMARY KEY");  
  23.                         combo_for_constraint[i].Items.Add("FOREIGN KEY");  
  24.                     }  
  25.                 }  
  26.    

Answers (2)