Hi,

I have two forms,
Form1, Form2
I need to show form2 first and then add form1 to form2. I did this in program.cs
Passing form2 object to form1 in constructor. am assigning the properties of form2 in form1 using the constructor object.

static class Program
    {
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Form2 frm2 = new Form2();
            Form1 frm = new Form1(frm2);
            frm.TopLevel = false;
            frm2.Controls.Add(frm);
            frm.Show();
            frm.Activate();
            frm.BringToFront();
            Application.Run(frm2);            
        }
    }

Problem is(frm2.show()), after assigning all the properties I could not reload the form2. coz form2 is already initialized and this line is not hitting the form2_load.

frm2.name="xxx";
frm2.show();

Please help me with this.

Hi Michael,
Thanks for your reply.
But what exactly I needed is, When the application starts, for the first time it should show form2(main form) and form1(settings form). After clicking the button1(save settings) on form1,some variables in form2 is getting assigned and form1 should hide. Form2 should get loaded with the controls based on button click event in form1.

And on each and every click on settings button in form2, form1 should get loaded.
I hope you understood my problem now.

frm2.Visible = false;
this.Visible = false;
frm2.ShowDialog();

This is refreshing form2.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.