0

1.In c# I want to show panel in form1 when i click a button in form 2. i create a method showpanel(){ panel1.show();} in form1 in this form1 i call showpanel() it is works fine. when i call with form2 it is not work.

In Form2:

private void panel1_MouseDoubleClick(object sender, MouseEventArgs e)
{          
    Form1 f1 = new Form1();
    f1.showpanel();
}

In Form1:

public void showpanel()
{
    panel1.Visible = true;
}

2.i also make panel public and call directly from form2 also

In Form2:

private void panel1_MouseDoubleClick(object sender, MouseEventArgs e)
{          
     Form1 f1 = new Form1();
     f1.panel1.Show();
     f1.panel1.Visible = true;
 }

but it also not work.

stuartd
  • 70,509
  • 14
  • 132
  • 163
Maniraj
  • 33
  • 5

1 Answers1

0

From form2 Before showing the form1 you need to make panel1 visible.

private void panel1_MouseDoubleClick(object sender, MouseEventArgs e)
    {          
         Form1 f1 = new Form1();
         f1.panel1.Visible = true;
         f1.panel1.Show();
     }
jignesh
  • 1,639
  • 1
  • 16
  • 18