multi forms in one desktop application

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • gilit golit
    New Member
    • Feb 2011
    • 27

    multi forms in one desktop application

    1. How do I define multi forms in the same winform app (C#) ?
  • GaryTexmo
    Recognized Expert Top Contributor
    • Jul 2009
    • 1501

    #2
    I believe you're looking to make an MDI Application... here's a few links with some information/examples.



    Comment

    • gilit golit
      New Member
      • Feb 2011
      • 27

      #3
      Thank
      But I ment standard application that pressing on a button in one form causes
      opening another form.
      nor multi documents at the same time

      Comment

      • GaryTexmo
        Recognized Expert Top Contributor
        • Jul 2009
        • 1501

        #4
        Oh, sorry. You can just open another form... a Form object has a Show and a ShowDialog method. Show opens the form and lets you interact with other forms in that application. ShowDialog opens it as modal, which means you can't change focus to any other form until you close that one.

        You just open it up in the button click event... here's a snippet.

        Code:
        ...
        private void button1_Click(object sender, EventArgs e)
        {
          OtherForm otherForm = new OtherForm();
          otherForm.ShowDialog();
        
          if (otherForm.SomeStringProperty == "SomeStringValue")
            // Do something
        }
        ...
        That's a fairly brief example but hopefully you get the idea. Let me know if you have questions :)

        Comment

        • gilit golit
          New Member
          • Feb 2011
          • 27

          #5
          Thanks alot
          I understood what you said.
          Now
          First I opened a C# winform application
          and implemented the form (Form1).
          Then I did Project->add windows form
          It opened relevant files. I implemeted them (Form2).

          But, When I wanted to define an object of class "Form2"
          in the handle of a button of form1, It did not recognize Form2.
          Maybe there is a need to somehow do
          some compilation or configuration connection between these two ???

          Regards

          Comment

          • gilit golit
            New Member
            • Feb 2011
            • 27

            #6
            ok
            Now, I added "using Form2NamesSpace; "

            and it seems working . Thanks again
            Yeee !!

            Comment

            • gilit golit
              New Member
              • Feb 2011
              • 27

              #7
              good !
              thanks

              How do I refer from one form to events in another form ?

              Comment

              Working...