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. How To access inner Control in custom user control

How To access inner Control in custom user control

Scheduled Pinned Locked Moved C#
tutorialquestion
8 Posts 4 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.
  • M Offline
    M Offline
    Mahdi_kishislan
    wrote on last edited by
    #1

    i creat custom control that have a lable. how can i expose all property of this lable for cotrol consumer

    R OriginalGriffO P 3 Replies Last reply
    0
    • M Mahdi_kishislan

      i creat custom control that have a lable. how can i expose all property of this lable for cotrol consumer

      R Offline
      R Offline
      Ron Beyer
      wrote on last edited by
      #2

      Make its access modifier public.

      OriginalGriffO M 3 Replies Last reply
      0
      • R Ron Beyer

        Make its access modifier public.

        OriginalGriffO Offline
        OriginalGriffO Offline
        OriginalGriff
        wrote on last edited by
        #3

        Bad idea! You should not expose controls directly - it locks your control format so you cannot make any changes without risking breaking external code that uses the controls in ways you did not anticipate, and also constrains you to always use that control in future, even if you should "replace that text box with a drop down list and a numeric up-down because that reflects better what the data is used for". If you did, you would break outside code and potentially annoy a lot of people whose code relies on yours. Instead, use a public property to get and set the value on your internal, hidden controls - that is why all controls default to private when you add them in the designer!

        This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre. Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
        "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

        1 Reply Last reply
        0
        • M Mahdi_kishislan

          i creat custom control that have a lable. how can i expose all property of this lable for cotrol consumer

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #4

          Please do not post the same question in two places - here and QA. It duplicates work and can annoy people.

          This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre. Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          1 Reply Last reply
          0
          • M Mahdi_kishislan

            i creat custom control that have a lable. how can i expose all property of this lable for cotrol consumer

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

            The way I would do it is I would wrap each property in a custom property that merely called the underlying property.

            Chill _Maxxx_
            CodeStash - Online Snippet Management | My blog | MoXAML PowerToys | Mole 2010 - debugging made easier

            1 Reply Last reply
            0
            • R Ron Beyer

              Make its access modifier public.

              M Offline
              M Offline
              Mahdi_kishislan
              wrote on last edited by
              #6

              tnx.good idead

              OriginalGriffO 1 Reply Last reply
              0
              • R Ron Beyer

                Make its access modifier public.

                M Offline
                M Offline
                Mahdi_kishislan
                wrote on last edited by
                #7

                tnx.good idea

                1 Reply Last reply
                0
                • M Mahdi_kishislan

                  tnx.good idead

                  OriginalGriffO Offline
                  OriginalGriffO Offline
                  OriginalGriff
                  wrote on last edited by
                  #8

                  No, it is not a good idea - it is a very bad idea. Remember your OOPs concepts - this breaks them (pretty much all of them) and makes future development and maintenance much harder. Just because you can do something, doesn't mean you should.

                  This message is manufactured from fully recyclable noughts and ones. To recycle this message, please separate into two tidy piles, and take them to your nearest local recycling centre. Please note that in some areas noughts are always replaced with zeros by law, and many facilities cannot recycle zeroes - in this case, please bury them in your back garden and water frequently.

                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
                  "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

                  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