المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : How do I call a method on the parent form from another form?



C# Programming
03-19-2010, 05:18 AM
Hi,

I am fairly new to programming and I am making member registration apllication.

The main form contains a DataGridView with all the checked in members. The DataGridView connects to a
stored procedure. This main form is also the start-up form.
In the search results form I can check in / out a member. This done by clicking a button that calls a stored procedure.

Now for my question:

After I click the checkin / out button I want to update the DataGridView in the main form.
I don't seem to be able to make this work.

Below is the code that I use.

The following method is placed on the main form. This is the method I want to call from the other form.

public void FillDataGrid()
{
this.aLL_CHECKED_IN_MEMBERTableAdapter.Fill(this.on_target_v1DataSet.ALL_CHECKED_IN_MEMBER);

}


I want to call this method through the following code, this code is located on a different form:

public void btnCheckIn_Click(object sender, EventArgs e)
{
Procedures.CallStoredProcedure.CHECK_IN_MEMBER(this.lblNumber.Text);
CheckInOut(this.lblNumber.Text);
frmMain cls = new frmMain();
cls.FillDataGrid();
}

Does anyboady have any ideas how I can tackle this?

Regards,
Paul Stol