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. Exposing constituent control properties in VS.NET

Exposing constituent control properties in VS.NET

Scheduled Pinned Locked Moved C#
csharpcssvisual-studiohelpquestion
2 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.
  • M Offline
    M Offline
    Matt Davison
    wrote on last edited by
    #1

    I have a situation where I wanted to expose the properties of a constituent control(TextBox in this case) of my user control in the property grid. I found this to be very simple by just making a public property for my TextBox and works fine. The problem is that it doesnt write the changes of the TextBox state to the code file. If I expose they properties of the TextBox directly off the user control it does save them to the code file. I guess my question is would be: Do I have to expose every property of the constituent control on the user control to get it to generate the code or is there a work around. Someone please point me in the right direction:(

    H 1 Reply Last reply
    0
    • M Matt Davison

      I have a situation where I wanted to expose the properties of a constituent control(TextBox in this case) of my user control in the property grid. I found this to be very simple by just making a public property for my TextBox and works fine. The problem is that it doesnt write the changes of the TextBox state to the code file. If I expose they properties of the TextBox directly off the user control it does save them to the code file. I guess my question is would be: Do I have to expose every property of the constituent control on the user control to get it to generate the code or is there a work around. Someone please point me in the right direction:(

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      The code is generated to get/set properties on your class - the container class in this case. It would set your property to whatever text you use. When the code is executed, your property is set at runtime which sets the property on the TextBox. If you're looking for a way to control the code generation so that setting your property actually serializes the code so that the child TextBox is set, you're not going to find an easy one and I'm not sure it's even possible since VS.NET (or any designer, like SharpDeveloper) is what provides the code serialization implementation. As far as exposing all the properties of a child control, you need to decide what you want to expose to the user. The whole idea of a complex container control is to encapsulate other controls as you require. If you end up exposing all the properties of a child control, then what's the point of encapsulating it in the first place?

      Microsoft MVP, Visual C# My Articles

      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