Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hide private child control property at design time

I have a container control with some private child control. How to hide the property browser from showing the control at design time. also it shows a lock and a square icon on each of the control at design time.

enter image description here

I tried to set for the control

<Browsable(False), DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden), Bindable(False)>
<EditorBrowsable(EditorBrowsableState.Never)>

also tried to set <DesignTimeVisible(False), ToolboxItem(False)> for the child control. but still shows up in the designer even though it is not editable.

Currently I am painting the control at design time and on runtime loading the real control. is there a simpler way to do this?

like image 640
bansi Avatar asked Oct 15 '22 13:10

bansi


1 Answers

Option 1 - Set GenerateMember = false

In the design mode of the base control, set GenerateMember property of the child control to false. This way the derived control wont allow selection of the button.

Option 2 - Using TypeDescriptor set a new non-working designer for the child control

Another trick is setting a new non-working designer for child control using typeDescriptor.AddAttributes, in the constructor of the base control, after initialize components:

TypeDescriptor.AddAttributes(this.button1, new DesignerAttribute(typeof(object)));
like image 113
Reza Aghaei Avatar answered Oct 20 '22 22:10

Reza Aghaei