Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Forms in a panel control?

Forms in a panel control?

Scheduled Pinned Locked Moved C#
helpdockertutorialquestion
4 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T Offline
    T Offline
    thompsons
    wrote on last edited by
    #1

    I have a main form that has a panel control and the user can select which of the two "child" forms to display in that panel control from a menu selection. Depending on which form is displayed in the panel, the app will display data from a Tektronix TDS-2024B scope or other data from an external DAQ (Data Acquisition module). The current code shows the forms without a problem. But if I switch between the two forms; data is no longer updated in the textboxes when I run a data capture routine for one form or the other. However, if I do not switch from one form display to the other after firing up the app, data is updated correctly. Example code for one of the form displays in the panel is: private void ScopeCapture_Click(object sender, EventArgs e) { frmTDS2024BScopeCapture TDS = new frmTDS2024BScopeCapture(); TDS.MdiParent = this; TDS.TopLevel = false; TDS.Dock = DockStyle.Fill; //Container this.panel1.Controls.Clear(); this.panel1.Controls.Add(TDS); TDS.Show(); currentTest = "TDS"; ////TDS.tbFreq.Text = "4578223"; //test only } The code for the second form is identical, except for the form reference. Could I be having a problem with the Z-order of the panel when switching from one form to the other? Hope someone has run into this before and can shed some light on the issue. I tried not to clutter this post with too many details. If further code is required, please advise. Thanks in advance, Steve. P.S. I have Googled, searched forums, etc till I'm blue in this face with this one.

    H 1 Reply Last reply
    0
    • T thompsons

      I have a main form that has a panel control and the user can select which of the two "child" forms to display in that panel control from a menu selection. Depending on which form is displayed in the panel, the app will display data from a Tektronix TDS-2024B scope or other data from an external DAQ (Data Acquisition module). The current code shows the forms without a problem. But if I switch between the two forms; data is no longer updated in the textboxes when I run a data capture routine for one form or the other. However, if I do not switch from one form display to the other after firing up the app, data is updated correctly. Example code for one of the form displays in the panel is: private void ScopeCapture_Click(object sender, EventArgs e) { frmTDS2024BScopeCapture TDS = new frmTDS2024BScopeCapture(); TDS.MdiParent = this; TDS.TopLevel = false; TDS.Dock = DockStyle.Fill; //Container this.panel1.Controls.Clear(); this.panel1.Controls.Add(TDS); TDS.Show(); currentTest = "TDS"; ////TDS.tbFreq.Text = "4578223"; //test only } The code for the second form is identical, except for the form reference. Could I be having a problem with the Z-order of the panel when switching from one form to the other? Hope someone has run into this before and can shed some light on the issue. I tried not to clutter this post with too many details. If further code is required, please advise. Thanks in advance, Steve. P.S. I have Googled, searched forums, etc till I'm blue in this face with this one.

      H Offline
      H Offline
      Henry Minute
      wrote on last edited by
      #2

      The only thing that seems 'odd' to me at first glance is the line TDS.MdiParent = this;. From the code you have posted I can see no need for this. By adding TDS to the panel, you are not allowing the Main Form to operate properly as an MDI Parent, and I would suggest that you at least try running your Application with the line commented out and see if it runs OK. I do not know if this will solve the problem entirely, but that line is certainly not helping.

      Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

      T 1 Reply Last reply
      0
      • H Henry Minute

        The only thing that seems 'odd' to me at first glance is the line TDS.MdiParent = this;. From the code you have posted I can see no need for this. By adding TDS to the panel, you are not allowing the Main Form to operate properly as an MDI Parent, and I would suggest that you at least try running your Application with the line commented out and see if it runs OK. I do not know if this will solve the problem entirely, but that line is certainly not helping.

        Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

        T Offline
        T Offline
        thompsons
        wrote on last edited by
        #3

        Thank you Henry for the reply. I will try what you recommend. I don't see many comments on the Web or MicroSoft on how to show forms in a panel control. Could be, I'm trying something that has potential problems that are not documented anywhere. As I mentioned, the forms show up in the panel control just fine. After switching between one and the other, the textboxes in those forms are no longer updated when expected. I'm using a PXI chassis from National Instruments to capture data from several voltage/current sources and as well as getting scope captures via a USB port from a Tektronix scope. Best Regards, Steve. BTW, I don't read medical books. Former medical student here... Then I got hooked on Math and programming and now this problem!

        H 1 Reply Last reply
        0
        • T thompsons

          Thank you Henry for the reply. I will try what you recommend. I don't see many comments on the Web or MicroSoft on how to show forms in a panel control. Could be, I'm trying something that has potential problems that are not documented anywhere. As I mentioned, the forms show up in the panel control just fine. After switching between one and the other, the textboxes in those forms are no longer updated when expected. I'm using a PXI chassis from National Instruments to capture data from several voltage/current sources and as well as getting scope captures via a USB port from a Tektronix scope. Best Regards, Steve. BTW, I don't read medical books. Former medical student here... Then I got hooked on Math and programming and now this problem!

          H Offline
          H Offline
          Henry Minute
          wrote on last edited by
          #4

          Good luck!

          thompsons wrote:

          I'm using a PXI chassis from National Instruments to capture data from several voltage/current sources and as well as getting scope captures via a USB port from a Tektronix scope.

          Please don't ask me anything about that part, way out of my depth!

          thompsons wrote:

          I don't see many comments on the Web or MicroSoft on how to show forms in a panel control. Could be, I'm trying something that has potential problems that are not documented anywhere

          There are several examples of this here on CP, if you search the articles/messages. The only thing that strikes me about it is a matter of personal preference. I would set the FormBorderStyle property to None, but that's just my preference and has nothing to do with your problem. At the end of the day Form is a descendant of Control and therefore should act like any other control. Here is a snippet from one of my apps:

          	private void btnForm\_Click(object sender, EventArgs e)
          	{
          		Form newForm = new Form();
          		newForm.TopLevel = false;
          		newForm.Parent = this;
          		newForm.Visible = true;
          		newForm.Location = new Point(10, 10);
          		newForm.Size = new Size(this.ClientSize.Width - 20, this.ClientSize.Height - this.panel1.Height - 20);
          		newForm.BackColor = Color.Bisque;
          		newForm.FormBorderStyle = FormBorderStyle.None;
          		newForm.Dock = DockStyle.Left;
          		this.Controls.Add(newForm);
          	}
          

          The only difference between yours and mine is that I add it directly to the parent form, you add it to a panel.

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups