Call the Load Event from one form after it has been loaded before
How can a form load event can be called from 1 form to another?
for example say I have two forms. And form1 is my main form and form2 is my ColumnListCheckBox form.
The form2 does the loading when the main form is loaded but if you insert a refresh button so the user can manually refresh the form as well, this should also refresh the load even in the form2. How can this be done?
Thanks!

Kirtan PatelRank #292 · 8.6K reputationPosted Nov 3, 2009, 1:58 AM EST
Suppose You have Two Form Form1 and Form 2 . Now Form1 having Button Refresh that Will Refresh The Content of
Running Form2 by Executing its Two Methods "EnablesDisableLoadButton()" and PopulateColumnCheckBox()
then
Form1 Refresh Button Code Would Like Below ( It will call that Two Methods From Running Instance of Form2)
---------------------------------------------------------
private void btnRefresh_Click(object sender, EventArgs e)
{
Form f2RunningInstance = Application.OpenForms["Form2"];
((Form2)f2RunningInstance).EnablesDisableLoadButton();
((Form2)f2RunningInstance).PopulateColumnCheckBox();
}
Form2 Code ( Here Note That those Two Methods Should Be "Public" )
--------------------------------------------------------------------------------------------
private void Form2_Load(object sender, EventArgs e)
{
PopulateColumnCheckBox();
EnablesDisableLoadButton();
}
public void EnablesDisableLoadButton()
{
//Any Code
}
public void PopulateColumnCheckBox()
{
//Any Code
}
friend , if my answer helps you then mark "Do you like this answer " check Box :)
Kirtan PatelRank #292 · 8.6K reputationPosted Nov 3, 2009, 12:06 AM EST
your idea to Refresh the Form is not proper :)
you should do this like
1.Write A Function For Code Which you Run At Form_Load Event .
2.after that When you press the refresh Button in Form1 .Locate the Running Instance of Form2 and Execute that Written Function on Form 2 :)
if my answer helps you please check "do you like this answer" :)
regor52 reputationPosted Nov 3, 2009, 12:16 AM EST
Nilanka DharmadasaRank #1,875 · 794 reputationPosted Nov 3, 2009, 12:42 AM EST
//In your form 2, create a new public method 'LoadMyControls'.
private void ColumnListCheckBox_Load(object sender, EventArgs e)
{
LoadMyControls();
}
public void LoadMyControls()
{
PopulateColumnCheckBox();
EnablesDisableLoadButton();
}
//Then call that new method in form 1.
private ColumnListCheckBox ColumnListCheckBox = new ColumnListCheckBox(); ColumnListCheckBox.LoadMyControls();
If my answer helps you, please accept it.
Kirtan PatelRank #292 · 8.6K reputationPosted Nov 3, 2009, 12:54 AM EST
I think you are doin mistake at locating the instance :)
can Upload your Project Files Zip to http://mediafire.com and Give me download link :)
i will resolve it Quickly and Tell you where you doing mistake in code :)
my mail ID is [email protected]
Happy Coding :)
regor52 reputationPosted Nov 3, 2009, 1:32 AM EST