Call PerformClick from another form

Hello, i have 2 forms, one is main where i show tasks created by user and second is for create new task an i want after create call performclick on button which refresh TabList but this function dont work, performclick is not called. Why? Thanks

1
2
3
4
5
var frm = (Form1)Owner;
if (frm != null)
{
     frm.button_0.PerformClick();
}


This is Form1
1
2
3
4
5
6
public partial class Form1....
{
    public Button button_0 = new Button();
......

}
Last edited on
Are you sure that frm is != null ?
Try
1
2
3
4
5
6
7
var frm = (Form1)Owner;
if (frm != null)
{
     frm.button_0.PerformClick();
}
else
   MessageBox.Show("frm is null");
i get frm is null, why?
I guess you didn't set the Owner.
And i need to ask, how can i set owner please?
In your main form you can set the owner of the second form.
1
2
3
Form2 frm2 = new Form2();
frm2.Owner = this;
frm2.ShowDialog();
Topic archived. No new replies allowed.