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. simple user control / panel question

simple user control / panel question

Scheduled Pinned Locked Moved C#
questiontutorial
3 Posts 3 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
    theStorminMormon
    wrote on last edited by
    #1

    OK, I'm just trying to learn how to use panels. I have a panel "pnlWorkArea" and I have a user control "uctrlNewCostTracker". I just want to write a button action that will make the user control show up in the panel (the button and the panel are both on frmMain). This should be easy, right? The ends can never justify the means. It is the means that determine the ends.

    W D 2 Replies Last reply
    0
    • T theStorminMormon

      OK, I'm just trying to learn how to use panels. I have a panel "pnlWorkArea" and I have a user control "uctrlNewCostTracker". I just want to write a button action that will make the user control show up in the panel (the button and the panel are both on frmMain). This should be easy, right? The ends can never justify the means. It is the means that determine the ends.

      W Offline
      W Offline
      Wjousts
      wrote on last edited by
      #2

      Just add the user control to the panels ControlCollection using Panel.Controls.Add

      1 Reply Last reply
      0
      • T theStorminMormon

        OK, I'm just trying to learn how to use panels. I have a panel "pnlWorkArea" and I have a user control "uctrlNewCostTracker". I just want to write a button action that will make the user control show up in the panel (the button and the panel are both on frmMain). This should be easy, right? The ends can never justify the means. It is the means that determine the ends.

        D Offline
        D Offline
        dbetting
        wrote on last edited by
        #3

        I do this frequently.

        UcInfo = new ucInfo(this); // Instantiate the UC
        UcInfo.Parent = pnl01; // Assign the panel as the UC parent
        UcInfo.ShowLookup = false; // I have preprossing in the UC that I want executed
        pnl01.Height = UcInfo.Height + 8; // In this case, I'm adjusting the size of the parent panel to the hieght of the UC
        UcInfo.Dock = DockStyle.Fill; // Now dock the UC into the panel
        pnl01.Dock = DockStyle.Top; // Position the panel on the form
        ... // There can be other preprocessing you might need done on the UC.
        pnl01.Visible = true; // Now show the panel

        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