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. Hiding control properties, Creating serializable control

Hiding control properties, Creating serializable control

Scheduled Pinned Locked Moved C#
designtutorialquestion
4 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.
  • A Offline
    A Offline
    Andy Rama
    wrote on last edited by
    #1

    Hi to all, I have created an Custom UserControl (inherited from UserControl class). 2 Questions, 1. How to hide the (inherited) properties of that control? without using Browseable() property I didn't get access to any class from System.Window.Forms.Design for ex. ControlDesigner even after adding it's reference 2. How to create usercontrol as serializable &/or deserializable? so that it's properties can be saved programmatically Regards, Aniket A. Salunkhe

    D 1 Reply Last reply
    0
    • A Andy Rama

      Hi to all, I have created an Custom UserControl (inherited from UserControl class). 2 Questions, 1. How to hide the (inherited) properties of that control? without using Browseable() property I didn't get access to any class from System.Window.Forms.Design for ex. ControlDesigner even after adding it's reference 2. How to create usercontrol as serializable &/or deserializable? so that it's properties can be saved programmatically Regards, Aniket A. Salunkhe

      D Offline
      D Offline
      DaveyM69
      wrote on last edited by
      #2

      No inherited property can be truly hidden. There are several ways to hide them from the designer, but they will still show up in intellisense. Any derived class should implement anything in its base or call the bases own implementation. The only true way to not have any properties apart from your own is to build your own from scratch without deriving from UserControl (or Control) or start with Component as it has no properties except Container and Site. UserControl Inheritance Tree ---------------------------- UserControl : ContainerControl ContainerControl : ScrollableControl, IContainerControl ScrollableControl : Control, IComponent, IDisposable Control : Component, IDropTarget, ISynchronizeInvoke, IWin32Window, IBindableComponent, IComponent, IDisposable Component : MarshalByRefObject, IComponent, IDisposable As you can see, there's alot of inheritance going on when you use UserControl

      Dave
      BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
      Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

      A 1 Reply Last reply
      0
      • D DaveyM69

        No inherited property can be truly hidden. There are several ways to hide them from the designer, but they will still show up in intellisense. Any derived class should implement anything in its base or call the bases own implementation. The only true way to not have any properties apart from your own is to build your own from scratch without deriving from UserControl (or Control) or start with Component as it has no properties except Container and Site. UserControl Inheritance Tree ---------------------------- UserControl : ContainerControl ContainerControl : ScrollableControl, IContainerControl ScrollableControl : Control, IComponent, IDisposable Control : Component, IDropTarget, ISynchronizeInvoke, IWin32Window, IBindableComponent, IComponent, IDisposable Component : MarshalByRefObject, IComponent, IDisposable As you can see, there's alot of inheritance going on when you use UserControl

        Dave
        BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
        Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

        A Offline
        A Offline
        Andy Rama
        wrote on last edited by
        #3

        Can you explain me with example? using System.ComponentModel; class TestControl : Container { } Here I am not getting interface for 'Site'.

        D 1 Reply Last reply
        0
        • A Andy Rama

          Can you explain me with example? using System.ComponentModel; class TestControl : Container { } Here I am not getting interface for 'Site'.

          D Offline
          D Offline
          DaveyM69
          wrote on last edited by
          #4

          using System.ComponentModel;
          public class TestControl : Component
          {
          }

          Derive from Component not Container. Any instance of TestControl only has two properties; Site and Container, unless you add more yourself of course.

          Dave
          BTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)
          Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)

          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