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. Design and Architecture
  4. better way to draw common ui interfaces on more than 1 form

better way to draw common ui interfaces on more than 1 form

Scheduled Pinned Locked Moved Design and Architecture
pythondatabasedesignquestion
8 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.
  • S Offline
    S Offline
    Simon_Whale
    wrote on last edited by
    #1

    I need a bit of approach advice. I have 2 forms that have the same custom section of form drawn in each. The controls are drawn according to some data in the database. At the moment I thought about copying the Code from one form to the other but I am sure there is a better way! Any pointer for me to read upon ?

    Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

    P L R 3 Replies Last reply
    0
    • S Simon_Whale

      I need a bit of approach advice. I have 2 forms that have the same custom section of form drawn in each. The controls are drawn according to some data in the database. At the moment I thought about copying the Code from one form to the other but I am sure there is a better way! Any pointer for me to read upon ?

      Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

      P Offline
      P Offline
      Pete OHanlon
      wrote on last edited by
      #2

      If the same piece of UI appears on more than 1 form, it would seem prudent to create that part of the UI as a UserControl and host it on both forms. The logic should be encapsulated neatly then.

      Forgive your enemies - it messes with their heads

      "Mind bleach! Send me mind bleach!" - Nagy Vilmos

      My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

      S 1 Reply Last reply
      0
      • P Pete OHanlon

        If the same piece of UI appears on more than 1 form, it would seem prudent to create that part of the UI as a UserControl and host it on both forms. The logic should be encapsulated neatly then.

        Forgive your enemies - it messes with their heads

        "Mind bleach! Send me mind bleach!" - Nagy Vilmos

        My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

        S Offline
        S Offline
        Simon_Whale
        wrote on last edited by
        #3

        potentially a blonde question here but is it considered better to pass the database data too it rather than getting the user control to query the database?

        Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

        P 1 Reply Last reply
        0
        • S Simon_Whale

          potentially a blonde question here but is it considered better to pass the database data too it rather than getting the user control to query the database?

          Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

          P Offline
          P Offline
          Pete OHanlon
          wrote on last edited by
          #4

          I would have a central repository for the database data. a cache if you like, and just query that from the user control - it's one location for the UC to talk to, and it's easy to implement using a static class.

          Forgive your enemies - it messes with their heads

          "Mind bleach! Send me mind bleach!" - Nagy Vilmos

          My blog | My articles | MoXAML PowerToys | Mole 2010 - debugging made easier - my favourite utility

          1 Reply Last reply
          0
          • S Simon_Whale

            I need a bit of approach advice. I have 2 forms that have the same custom section of form drawn in each. The controls are drawn according to some data in the database. At the moment I thought about copying the Code from one form to the other but I am sure there is a better way! Any pointer for me to read upon ?

            Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

            L Offline
            L Offline
            Lost User
            wrote on last edited by
            #5

            As an alternative; create a form that contains the common controls, and inherit both other forms from there. Making it a UserControl, as already suggested, would be a better idea though :)

            Bastard Programmer from Hell :suss:

            J 1 Reply Last reply
            0
            • L Lost User

              As an alternative; create a form that contains the common controls, and inherit both other forms from there. Making it a UserControl, as already suggested, would be a better idea though :)

              Bastard Programmer from Hell :suss:

              J Offline
              J Offline
              John T Emmatty
              wrote on last edited by
              #6

              Personally, i would go for the inheritance method even thought user control is a great approach.

              L 1 Reply Last reply
              0
              • J John T Emmatty

                Personally, i would go for the inheritance method even thought user control is a great approach.

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                John T.Emmatty wrote:

                Personally, i would go for the inheritance method even thought user control is a great approach.

                It's an option; but you can use multiple UserControls in different forms - and inherit only from one form at a time.

                Bastard Programmer from Hell :suss:

                1 Reply Last reply
                0
                • S Simon_Whale

                  I need a bit of approach advice. I have 2 forms that have the same custom section of form drawn in each. The controls are drawn according to some data in the database. At the moment I thought about copying the Code from one form to the other but I am sure there is a better way! Any pointer for me to read upon ?

                  Lobster Thermidor aux crevettes with a Mornay sauce, served in a Provençale manner with shallots and aubergines, garnished with truffle pate, brandy and a fried egg on top and Spam - Monty Python Spam Sketch

                  R Offline
                  R Offline
                  Rahul Rajat Singh
                  wrote on last edited by
                  #8

                  Why not have a custom control that wil talk to database and render itself accordingly. this can be used on both the forms.

                  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