Opening new forms within C#

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Peter van der Zee
    New Member
    • Dec 2009
    • 3

    Opening new forms within C#

    L.S.,

    I'm an ex-C programmer and just started programming in C#.
    (Visual C# 2008 Express Edition)

    At the moment I'm re-writing a C-program in C# and my problem is most likely very simple, but sofar I've not been able to solve this problem.

    In the program I'm writing I've added a Windows Form via Project/Add Windows Form.
    My question is how can I activate this Form within my program?

    Thanks and Kind Regards,

    Peter
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    Instantiate a new object for your form, then call the Show method on it.

    Code:
    MyForm theForm = new MyForm();
    theForm.Show();
    Where MyForm is the class name for your Form object.



    You'd place that code where you wanted to form to appear. If you want the form's reference to persist, you'd make it a member variable.

    If by "C programmer" you mean straight C and not C++, you might want to take a few tutorials to get the hang of object oriented. I know when I first made the switch it was a bit of a shift in mind-set.

    Comment

    • Peter van der Zee
      New Member
      • Dec 2009
      • 3

      #3
      Hi Gary,

      Thank you very much,
      Indeed I used to program in straight C (Turbo C)

      Kind Regards,

      Peter

      Comment

      Working...