A form within a form in 2005

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • =?Utf-8?B?Unlhbg==?=

    A form within a form in 2005

    I have three forms in my application; frmMain being the main form:
    frmMain containing two button; btnDisplayForm1 and btnDisplayForm2
    FormA containing a button btnProcessReque stA
    FormB containing a button btnProcessReque stB

    frmMian is displayed and the FormB is displayed inside frmMain using
    SetParent; I click on btnDisplayForm1 which fires up the following code:
    FormA frm = new FormA ();
    Button btn = frm.btnProcessR equestA;
    this.InvokeOnCl ick(btn, EventArgs.Empty );

    When btnProcessReque stA is fired up on FormA; it displays FormB.

    How do I display FormB inside frmMian?
  • =?Utf-8?B?Unlhbg==?=

    #2
    RE: A form within a form in 2005

    I have tried the following code but got the error: {"Unable to find an entry
    point named 'SetParent' in DLL 'gdi32.dll'.":" "}

    FormB formB = new FormB();
    frmMain fMain = new frmMain
    SetParent(formB .Handle, fMain.Handle);
    formB.Show();




    "Ryan" wrote:
    I have three forms in my application; frmMain being the main form:
    frmMain containing two button; btnDisplayForm1 and btnDisplayForm2
    FormA containing a button btnProcessReque stA
    FormB containing a button btnProcessReque stB
    >
    frmMian is displayed and the FormB is displayed inside frmMain using
    SetParent; I click on btnDisplayForm1 which fires up the following code:
    FormA frm = new FormA ();
    Button btn = frm.btnProcessR equestA;
    this.InvokeOnCl ick(btn, EventArgs.Empty );
    >
    When btnProcessReque stA is fired up on FormA; it displays FormB.
    >
    How do I display FormB inside frmMian?

    Comment

    • Ignacio Machin ( .NET/ C# MVP )

      #3
      Re: A form within a form in 2005

      On Aug 6, 12:17 pm, Ryan <R...@discussio ns.microsoft.co mwrote:
      I have three forms in my application; frmMain being the main form:
      frmMain containing two button; btnDisplayForm1 and btnDisplayForm2
      FormA containing a button btnProcessReque stA
      FormB containing a button btnProcessReque stB
      >
      frmMian is displayed and the FormB is displayed inside frmMain using
      SetParent; I click on btnDisplayForm1 which fires up the following code:
      FormA frm = new FormA ();
      Button btn = frm.btnProcessR equestA;
      this.InvokeOnCl ick(btn, EventArgs.Empty );
      >
      When btnProcessReque stA is fired up on FormA; it displays FormB.
      >
      How do I display FormB inside frmMian?
      why you do that?
      why not use a Panel instead of a form?

      Comment

      • =?Utf-8?B?Unlhbg==?=

        #4
        Re: A form within a form in 2005

        It has to be a form for what I am trying to accomplish.

        "Ignacio Machin ( .NET/ C# MVP )" wrote:
        On Aug 6, 12:17 pm, Ryan <R...@discussio ns.microsoft.co mwrote:
        I have three forms in my application; frmMain being the main form:
        frmMain containing two button; btnDisplayForm1 and btnDisplayForm2
        FormA containing a button btnProcessReque stA
        FormB containing a button btnProcessReque stB

        frmMian is displayed and the FormB is displayed inside frmMain using
        SetParent; I click on btnDisplayForm1 which fires up the following code:
        FormA frm = new FormA ();
        Button btn = frm.btnProcessR equestA;
        this.InvokeOnCl ick(btn, EventArgs.Empty );

        When btnProcessReque stA is fired up on FormA; it displays FormB.

        How do I display FormB inside frmMian?
        >
        why you do that?
        why not use a Panel instead of a form?
        >

        Comment

        • =?Utf-8?B?Unlhbg==?=

          #5
          Re: A form within a form in 2005

          Ignacio,
          If I go with your suggestion and use a panel to display FormA and FormB; how
          do I pass values between these two forms?

          If I use the code:
          FormA frm = new FormA();
          Button btn = frm.button1;
          this.InvokeOnCl ick(btn, EventArgs.Empty );

          the button click event is invoked but the form is displayed outside the
          panel and the values aren't passed to FormB. The code for the FormB is:
          Form3 frm = new Form3();
          frm._textBox1 = _textBox1;
          frm.Show();

          I need to toggle between two forms and pass value between them.

          Thanks


          "Ryan" wrote:
          It has to be a form for what I am trying to accomplish.
          >
          "Ignacio Machin ( .NET/ C# MVP )" wrote:
          >
          On Aug 6, 12:17 pm, Ryan <R...@discussio ns.microsoft.co mwrote:
          I have three forms in my application; frmMain being the main form:
          frmMain containing two button; btnDisplayForm1 and btnDisplayForm2
          FormA containing a button btnProcessReque stA
          FormB containing a button btnProcessReque stB
          >
          frmMian is displayed and the FormB is displayed inside frmMain using
          SetParent; I click on btnDisplayForm1 which fires up the following code:
          FormA frm = new FormA ();
          Button btn = frm.btnProcessR equestA;
          this.InvokeOnCl ick(btn, EventArgs.Empty );
          >
          When btnProcessReque stA is fired up on FormA; it displays FormB.
          >
          How do I display FormB inside frmMian?
          why you do that?
          why not use a Panel instead of a form?

          Comment

          • Ignacio Machin ( .NET/ C# MVP )

            #6
            Re: A form within a form in 2005

            On Aug 6, 7:20 pm, Ryan <R...@discussio ns.microsoft.co mwrote:
            Ignacio,
            If I go with your suggestion and use a panel to display FormA and FormB; how
            do I pass values between these two forms?  
            See it like this, instead of using form use a control , so you have
            two controls ControlA & ControlB hosted in the same form. how do you
            pass values between then depends if either ControlA or ControlB knows
            about the other.
            In a templated solution you will have methods in the container
            (Form1) that detect thte changes in ControlA and then call the method
            in ControlB

            hope that it's clear for you. if not post back

            Comment

            • =?Utf-8?B?Unlhbg==?=

              #7
              Re: A form within a form in 2005

              Could you please privde a sample code???

              "Ignacio Machin ( .NET/ C# MVP )" wrote:
              On Aug 6, 7:20 pm, Ryan <R...@discussio ns.microsoft.co mwrote:
              Ignacio,
              If I go with your suggestion and use a panel to display FormA and FormB; how
              do I pass values between these two forms?
              >
              See it like this, instead of using form use a control , so you have
              two controls ControlA & ControlB hosted in the same form. how do you
              pass values between then depends if either ControlA or ControlB knows
              about the other.
              In a templated solution you will have methods in the container
              (Form1) that detect thte changes in ControlA and then call the method
              in ControlB
              >
              hope that it's clear for you. if not post back
              >

              Comment

              Working...