hi,
i placed a combobox in a form inside a groupbox and i added items to it at design time itself using th property pane.i have even placed a button in the same form ,which would direct to another form and there i have placed a textbox ,after getting input from the user i want it to be added to the items already existing in the combobox in the previous form.
i have used th following code
Form1:
private void button1_Click_1(object sender, EventArgs e)
{
Form2 fr2= new Form2();
fr2.Show();
}
Form2
private void button1_Click(object sender, EventArgs e)
{
Form1 fr1 = new Form1();
fr1.comboBox4.Items.Add(textBox1.Text);
fr1.Refresh();
}
Loading
Nilanka DharmadasaPosted Jan 20, 2010, 1:57 AM
I don't think any of the above solutions will fit for your requirement.
Here is the code to do exactly what you want.
Run it and see.
If you find my answer helpful, please do not forget to tick 'Do you like this answer' checkbox.
Sam HobbsPosted Jan 19, 2010, 4:24 PM
I will guess at the question. If I understand the question, then what I would do is to do the Add in Form1 after showing Form2. You definitely do not want to create a new Form1 in Form2.