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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Visual Inheritance, and Default Property Values

Visual Inheritance, and Default Property Values

Scheduled Pinned Locked Moved C#
designoophelpquestion
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.
  • B Offline
    B Offline
    big_trev
    wrote on last edited by
    #1

    Here is the situation. I have a Form, called Form1 that contains a button, this button is marked as private. I have another Form, called Form2 the inherits from Form1. I Want Form2 to be able to Show and hide the button in the base class, without exposing the button as protected / or public. I Have created a public property on Form1 which has Get/Set into button.Visible property. All should work ok i can hear you shouting. In the form2 designer, i can see the property mentioned above, and i can change its value, and the button obediantly shows and hides it self as expected. The problem is that When i set enabled to true, it adds code to the designer generated section, which speifically sets my property to true, and when i set it to false, it removes this code, but it does Not add code to set it to false. The defualt value of the property is set to true, but this has no effect. I realise i can call this property in my form load, or in a constructor, but i would like to get the design time support. Other properties such as Enable work fine. Any idas? Trev

    T 1 Reply Last reply
    0
    • B big_trev

      Here is the situation. I have a Form, called Form1 that contains a button, this button is marked as private. I have another Form, called Form2 the inherits from Form1. I Want Form2 to be able to Show and hide the button in the base class, without exposing the button as protected / or public. I Have created a public property on Form1 which has Get/Set into button.Visible property. All should work ok i can hear you shouting. In the form2 designer, i can see the property mentioned above, and i can change its value, and the button obediantly shows and hides it self as expected. The problem is that When i set enabled to true, it adds code to the designer generated section, which speifically sets my property to true, and when i set it to false, it removes this code, but it does Not add code to set it to false. The defualt value of the property is set to true, but this has no effect. I realise i can call this property in my form load, or in a constructor, but i would like to get the design time support. Other properties such as Enable work fine. Any idas? Trev

      T Offline
      T Offline
      tarasn
      wrote on last edited by
      #2

      Try to add DesignerSerializationVisibility attribute: [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public bool Description { get { return myButton.Visible; } set { myButton.Visible = value; } } DevIntelligence.com - My blog for .Net Developers

      B 1 Reply Last reply
      0
      • T tarasn

        Try to add DesignerSerializationVisibility attribute: [DesignerSerializationVisibility(DesignerSerializationVisibility.Content)] public bool Description { get { return myButton.Visible; } set { myButton.Visible = value; } } DevIntelligence.com - My blog for .Net Developers

        B Offline
        B Offline
        big_trev
        wrote on last edited by
        #3

        Unfortunately this does not have any effect. I believe that for some reason the designer believes the default value is set to false, so that when i set it to false, it does not add any code.

        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