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 a control through a property

Exposing a control through a property

Scheduled Pinned Locked Moved C#
help
3 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.
  • R Offline
    R Offline
    Richard Parsons
    wrote on last edited by
    #1

    Hello everyone. I have an interesting problem that I need help with. I'm sure someone else has already had this problem. I have a custom control (either win or web because I have both doing this) and this control contains other controls such as a label and richtextbox. Well I have a few public properties that set properties on the internal controls but I also have a property that exposes the internal control as a property. My problem is that when I goto the designer and set properties though the control exposed though the property none of the settings are kept, however if I set the properties on the exposed control in code behind everything works fine. Any help would be apprciated -Richard

    S 2 Replies Last reply
    0
    • R Richard Parsons

      Hello everyone. I have an interesting problem that I need help with. I'm sure someone else has already had this problem. I have a custom control (either win or web because I have both doing this) and this control contains other controls such as a label and richtextbox. Well I have a few public properties that set properties on the internal controls but I also have a property that exposes the internal control as a property. My problem is that when I goto the designer and set properties though the control exposed though the property none of the settings are kept, however if I set the properties on the exposed control in code behind everything works fine. Any help would be apprciated -Richard

      S Offline
      S Offline
      spif2001
      wrote on last edited by
      #2

      [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] makes sure it is saved - put that in front of your control property

      1 Reply Last reply
      0
      • R Richard Parsons

        Hello everyone. I have an interesting problem that I need help with. I'm sure someone else has already had this problem. I have a custom control (either win or web because I have both doing this) and this control contains other controls such as a label and richtextbox. Well I have a few public properties that set properties on the internal controls but I also have a property that exposes the internal control as a property. My problem is that when I goto the designer and set properties though the control exposed though the property none of the settings are kept, however if I set the properties on the exposed control in code behind everything works fine. Any help would be apprciated -Richard

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

        if u have custom properties on that control property, be sure to use [DefaultValue(false)] on the properties if they are primitive types (int,string etc.). If u have object properties use the [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] attribute and go into that object and use the [DefaultValue(false)] attribute. etc. etc.

        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