Code Snippet
---------------------------------------------------------------------------
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
DoSomething();
}
public void DoSomething()
{
//Have your implementation here for e.g:
this.button1.Dock = DockStyle.Fill;
}
}
--------------------------------------------------------------------------
public partial class Form2 : Form
{
public Form2()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Program.CallForm1DoSomething();
}
}
---------------------------------------------------------------------------
// In the Program class add this method:
public static void CallForm1DoSomething()
{
//If Form1 is already open
foreach (Form form in Application.OpenForms)
{
if (form is Form1)
{
((Form1)form).DoSomething();
}
}
// If Form1 is not already open create an instance and call DoSeomthing() on that
}
-----------------------------------------------------------------------------------------------------------------------------------------