Click here to Skip to main content
15,902,198 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to fetch data from TextBox to a ComboBox after Button.Click event.
Posted
Updated 30-Oct-10 8:04am
v3

Example:

private void button1_Click(object sender, EventArgs e)
        {
            comboBox1.Items.Add(txtName.Text);
        }



Please vote and Accept Answer if it Helped.
 
Share this answer
 
v2
Handle the button Click event, and use:
myComboBox.Items.Add(myTextBox.Text);
 
Share this answer
 
This is such an elementary thing to do that I suspect you are new to either programming in general or at least to C#.

Bearing this in mind I will not be too hard on you but if anyone gives you the solution you will never become a programmer.

Your task can be divided into two parts
1) Getting the contents of a TextBox
2) Adding an item to a ComboBox


Use those two as search phrases and then try to put what you find together into some code.

Once you have tried and if you are still stuck, ask again showing the code you used and explaining the problem clearly.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900