Here, I will explain how to use a combo box in a Windows application. Before this I explain how to delete selected data from the database.
Step 1: Registration form with a ComboBox
Drag and down a ComboBox and a button from the Toolbox and provide the name of the button as "Add string".
![registration form with a combo box]() Step 2:
Step 2: Code1
At first step I want that when I enter a name and click the Button (Add string) then that name shows in the ComboBox.
So click on the Add String button and write this code.
 
![combo box]() 
- private void Addstring_Click(object sender, EventArgs e)  
- {  
-     string namestr = Name_txt.Text;  
-     comboBox1.Items.Add(namestr);  
- }  
 
 Step 3: Output for code1
When you enter a name in the TextBox and click on the button (add string). You will see that the name will show in the comboBox.
 
![button]() Step 4:
Step 4: Code2
Now if we want, when I click on any name in the ComboBox that the name shows in a TextBox. so now for the code for that. Click on the combo box and write this code. I want that selected name from the combo box shown in the Id TextBox.
- private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)  
- {  
-     Eid_txt.Text = comboBox1.text;  
- }  
 
 Step 5: Output for code2
Now select any name in the ComboBox and that name will be shown in the Id TextBox.