previous
Next
Here i will explain how to use combo box in window application. Before this i explain that delete selected data from database.
Step(1) :- registration form with a combo box
Drag and down a Combo box and a button from tool Box. And give the name of button As "Add string"
Step(2) :- Code1
At first step i want that when i enter name and click on Button(Add string) then that name show in combo box.
So click on Add String button and write this code.
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 name textbox and click on button(add string) you will see taht name will show in comboBox.
Step(4) :- Code2
Now if we want that when i click on any name which is in combobox that name show in a textbox. so code for that.Click on combo box and write this code. I want that selected name from combo box show in 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 combobx that name will show in Id text box.
Next
No comments:
Post a Comment