I want to fill a combobox on Form1 , when the OK button on Form2 is clicked.
First, the Load Form2 button on Form1 is clicked to display Form2.
Then, Form2 appears, and if OK(Button on Form2) is pressed then the Form1 ComboBox must be filled with values from a SQL SERVER database table.
public partial class FORM1 : Form
{
public void LoadValue()
{
string query = "SELECT FullName FROM Studs ";
SqlCommand cmd = new SqlCommand(query, FORM1conn);
SqlDataReader reader = cmd.ExecuteReader();
while (reader.Read())
{
FORM1COMBOBOX.Items.Add(reader.GetString(0));
}
}
}
public partial class FORM2 : Form
{
private void FORM2_OK_Button_Click(object sender, EventArgs e)
{
//HERE I WANT TO CALL THE LOADVALUE() METHOD OF FORM1 ????????
}
}

EDIT:
In form2.cs :
public partial class FORM2 : Form
{
public FORM2(SqlConnection connfromFORM3)
{
Form2Conn = connfromFORM3;
InitializeComponent();
}
private Form1 form1;
public SELECTGROUPHEADDIALOG(FORM1 form1) : this()
{
this.form1 = form1;
}
private void FORM2_OK_Button_Click(object sender, EventArgs e)
{
//HERE I WANT TO CALL THE LOADVALUE() METHOD OF FORM1 ????????
}
}
Updated
You can try passing Form1 instance in the constructor of Form2
Example:
Updated
try this: