Dear Team,
I have a derived TextBox with the tool functionality to clear TextBox contents.
The derived control is TextBoxExt and it has a property ClearTool, which dynamically adds/removed the tool with a cross (x).
The ClearTool property should have default value “true”.
I have troubles to make it work in the designer:
If I set ClearTool property to “true” outside TextBoxExt.InitializeComponent, the VS2019 designer does not initialize the tools.
If I set ClearTool property to “true” inside TextBoxExt.InitializeComponent, the VS2019 keeps adding multiple ComponentTools to the instance of the textbox.
This happens if I change the ClearTool value True->False->True in the designer for the instance of the control (e.g. textBoxExt2), and then close and re-open the designer.
Maybe related is that the “Tools” property of the textbox instance in VS designer shows “Read-Only”, but nevertheless allows modifications of the Tools collection.
Because I do not want the tools of the base control to be added to the instance of the control at the design time, I cannot set ClearTool property in the InitializeComponent of the base class.
Maybe I need to take care the visuals myself during design time.
Here are the issues:
If you want to manage the tools collection by code add:
[Browsable(false)] [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)] public new ComponentToolCollection Tools { get => base.Tools; }
Please login first to submit.