Hiding control properties, Creating serializable control
-
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
-
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
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 UserControlDave
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) -
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 UserControlDave
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) -
Can you explain me with example? using System.ComponentModel; class TestControl : Container { } Here I am not getting interface for 'Site'.
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)