Skip to content
Loading
Remove the item from ComboBox once it's been selected in the previous
  • Tamil Rk
    Hello Muhammad Ahsan,
     
    Try the below code. If the below code does not solve your problem, please explain what is the exact requirement.
     
    I have corrected based on shared your code knowledge. let me know if you need any help with this requirement.
    1.  ComboBox[] combo_for_constraint = new ComboBox[10];  
    2.             int combo_for_constraint_x = 250, combo_for_constraint_y = 50;  
    3.             for (int i = 1; i < 10; 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.                 panel1.Controls.Add(combo_for_constraint[i]);  
    12.                 panel1.ResumeLayout(false);  
    13.                 combo_for_constraint_y += 40;  
    14.                 panel1.Refresh();  
    15.                 combo_for_constraint[i].Items.Add("UNIQUE");  
    16.                 combo_for_constraint[i].Items.Add("PRIMARY KEY");  
    17.                 combo_for_constraint[i].Items.Add("FOREIGN KEY");  
    18.                 if (i >= 2)  
    19.                 {  
    20.                     combo_for_constraint[i].Items.Remove(combo_for_constraint[i - 1].Text);  
    21.                 }  
    22.                 combo_for_constraint[i].SelectedIndex = 0;  
    23.             }  
    Good Luck. 
    0