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. Change user controls in runtime using c#

Change user controls in runtime using c#

Scheduled Pinned Locked Moved C#
csharpvisual-studiowinforms
6 Posts 5 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.
  • B Offline
    B Offline
    bensonbenadict
    wrote on last edited by
    #1

    Hello, I have a default page on which there are three user controls put inside three panels within the page. Based on a click event of a button in any of the user control, i want to unload a user control in the page and load a diferent user control in its place. I am using VS 2008 and C# as the code behind... Your inputs would be very helpful....Thanks in advance

    A C realJSOPR 3 Replies Last reply
    0
    • B bensonbenadict

      Hello, I have a default page on which there are three user controls put inside three panels within the page. Based on a click event of a button in any of the user control, i want to unload a user control in the page and load a diferent user control in its place. I am using VS 2008 and C# as the code behind... Your inputs would be very helpful....Thanks in advance

      A Offline
      A Offline
      Abhijit Jana
      wrote on last edited by
      #2

      I believe this is a ASP.Net Question , So please post it on asp.net forum.

      cheers, Abhijit CodeProject.Com MVP

      S 1 Reply Last reply
      0
      • B bensonbenadict

        Hello, I have a default page on which there are three user controls put inside three panels within the page. Based on a click event of a button in any of the user control, i want to unload a user control in the page and load a diferent user control in its place. I am using VS 2008 and C# as the code behind... Your inputs would be very helpful....Thanks in advance

        C Offline
        C Offline
        Colin Angus Mackay
        wrote on last edited by
        #3

        You could make the Set the Visible property on the controls to the appropriate value so they are not rendered to the client unless they need to be.

        * Developer Day Scotland 2 - Free community conference * The Blog of Colin Angus Mackay


        Vogon Building and Loan advise that your planet is at risk if you do not keep up repayments on any mortgage secured upon it. Please remember that the force of gravity can go up as well as down.

        1 Reply Last reply
        0
        • A Abhijit Jana

          I believe this is a ASP.Net Question , So please post it on asp.net forum.

          cheers, Abhijit CodeProject.Com MVP

          S Offline
          S Offline
          sudhanvag
          wrote on last edited by
          #4

          You can do it using delegates. Create a delegate in the usercontrol with some return type / parameters with which you can set the visibility of the usercontrol, add an event for this delegate. Add a button with a button click event in user ctrl. Call the event in the webpage which in turn should call the user control's button click event. Try this out. Cheers, Sudhanva

          1 Reply Last reply
          0
          • B bensonbenadict

            Hello, I have a default page on which there are three user controls put inside three panels within the page. Based on a click event of a button in any of the user control, i want to unload a user control in the page and load a diferent user control in its place. I am using VS 2008 and C# as the code behind... Your inputs would be very helpful....Thanks in advance

            realJSOPR Offline
            realJSOPR Offline
            realJSOP
            wrote on last edited by
            #5

            I would personally instantiate all of them with the Visible property set to false, and then show/hide them as necessary. You can even initialize them when he VisibleChanged event is fired.

            "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
            -----
            "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

            B 1 Reply Last reply
            0
            • realJSOPR realJSOP

              I would personally instantiate all of them with the Visible property set to false, and then show/hide them as necessary. You can even initialize them when he VisibleChanged event is fired.

              "Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997
              -----
              "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

              B Offline
              B Offline
              bensonbenadict
              wrote on last edited by
              #6

              Thank you for the response. But here i am having around 50-60 controls now and the number is again going to increase. Do you think its a good idea to load as many number of controls on the form and keep its visible property false? The requirement is something as that of how Microsoft Dynamics work. We have one default page with left and main content panels that holds the user-controls which keep changing as per the button clicked...

              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