I'm trying to add an item to combobox that is in one form and the button I'm trying to do that with is in a different form.
Form1 is the form with the combobox and Form2 is the form with the button.
This is the code I tried:
private void dodajGumb_Click(object sender, EventArgs e)
{
var frm2 = new Form1();
frm2.comboFilmovi.Items.Add(imeText.Text);
}
I also tried to create a public method in form1.cs like this:
public void AddItem(string item)
{
comboFilmovi.Items.Add(item);
}
and this code in form2.cs:
var fr2 = new Form1();
fr2.AddItem(imeText.Text + " - " + datum.Value.ToString("dd-MM-yyyy") + " - " + vrijemeText.Text);
I don't get any errors, it's just that nothing happens, no new item in combobox. Any advice?