C# Show Form on button click

I am relatively new in C#.

I have the Form1 with the Button on it.  On Button_click event I need to open another form.

Since I am working with in a structured project I first tried to use method that already proved working.

Below are 3 lines of codes that worked for me when the form fTaskChange was to be opened from the Tree node click on another form - another "this"(means form).  This form "this" has panel1 on it.  Below is how it worked to open the Form fTaskChange in the panel1.

TaskChange.TaskChange fTaskChange = new TaskChange.TaskChange();
fTaskChange.Dock = DockStyle.Fill;

But under Button_click method on another form if I step through codes I see that all the tasks that have to happen before the form fTaskChange show up are completed, but the form is not seen.

TaskChange.TaskChange fTaskChange = new TaskChange.TaskChange();
fTaskChange.Dock = DockStyle.Fill;

I have tried another method too:

TaskChange.TaskChange fTaskChange = new TaskChange.TaskChange();
            staticVar = this;

This made "this" form to hide, but I don't see my form.

Please help.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
Not sure...but if you really are dealing with FORMS, then TopLevel() needs to be false:
TaskChange.TaskChange fTaskChange = new TaskChange.TaskChange();
fTaskChange.TopLevel = false;
fTaskChange.Dock = DockStyle.Fill;

Open in new window

Also, if there was another form already in Panel2 then you'd need to either clear out Panel2, or bring the new form to the front.
AquarusAuthor Commented:
What was actually happenning, is that structured by the project I used UserControl instead of WINDOWS .FOrm class.  I have changed that and now I see the form modally.

But it has a weird size - very small.  It is 750 / 600 in pixels in design view, but on run time - it is smal and its borders are not even sizable.

Please help.  Time issue already.
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
You may need to change FormBorderStyle():

The change in size could be a Font issue.  Are you changing it at run-time?

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
AquarusAuthor Commented:
FormBorderStyle is set to sizable.
 But the Autosize was set to True.  I have changed it to False and removed Grow and Shrink from Autosize Mode. Now it shows in its correct size.

Now I need to balance the deimnsions of grid on the form and the form itself.  I'll be continue working but If there is anything that may speed me up on this - i will appreciate greatly
Mike TomlinsonHigh School Computer Science, Computer Applications, and Mathematics TeachersCommented:
"Balance" it how?  You can use Anchor()/Dock() to control the sizing of controls.  For more control, use the TableLayoutPanel().
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.