Properties for user controls
-
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 same options which are displayed for selecting the color for the satndard properties like 'BackColor'. Then the user must be able to select the required color from these options & the value must be stored in that specific property. Kindly help me to acheieve the above scenarios Best Regards, Abhilash Chandran
-
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 same options which are displayed for selecting the color for the satndard properties like 'BackColor'. Then the user must be able to select the required color from these options & the value must be stored in that specific property. Kindly help me to acheieve the above scenarios Best Regards, Abhilash Chandran
1. I don't know 2. If your property datatype is a structure, or class then the property will appeare like location(x,y) as you mentioned with the "+" sign in property window. What you should do is to use .NET's structures and classes ( as location is a "point" datatype I guess) or define new structures/classes as nested datatypes in your code and use them. 3.as I mentioned in 2, .Net uses system.drawings.color (I guess) for colors. If you simply set this class as the datatype for your property, then the colorpicker will appear in property window.