1
Answer

Add/Remove Properties to User Controls

Abhilash

Abhilash

17y
2.4k
1

Dear All,

I am making a Windows Control Library(user control) using VS.NET & C#.NET. Now, i am facing 3 problems:
1.In this control, i wants to remove some of the properties which are available by default to the controls. These properties must be removed from the 'Properties window' of the usercontrol. Also the user must not be able to set these properties using code.
I am able to remove the properties from the 'Properties window' by inheriting a class from the System.Windows.Forms.Design.ScrollableControlDesigner & removing the properties by overriding the PreFilterProperties function as show below:
protected override void PreFilterProperties(System.Collections.IDictionary properties)
{
properties.Remove("BackColor");
}
But, doing so, this property is available to be set from the code. How can i remove this property fully?

2.I wants to create a property for the control which has sub properties, like the 'Location' property of a button, which has sub properties as 'X, Y & Locked'.
My new property for the control must have some subproperties like this. How can i achieve this?

3.I wants to add a property to the user control which allows the user to select a color. When the user selects this property, it must display the color pallate to select the color, the same way the color pallate is displayed for the user to select the standard properties like 'backColor'
Then the user must be able to select the required color from these options & we must be able to use the value of this property as required.

Kindly help me to acheieve the above scenarios

Best Regards,
Abhilash Chandran

Answers (1)