Note that there are some explanatory texts on larger screens.

plurals
  1. PO.NET Custom Control (ToolStripControlHost) Wreaks Havoc on the Designer
    text
    copied!<p>I need to have a MaskedTextBox in a ToolStrip, which isn't included by default, so I followed some advice I found online, and created custom control that inherits from ToolStripControlHost. What I've created works great when I'm running the application, but it really messes up the designer. By "messes up", I mean the custom control (Along with some others) disappear from the ToolStrip. Also I can no longer add new controls to the ToolStrip, and I can't select the existing controls on the ToolStrip to edit them.</p> <p>Here's my class.</p> <pre><code>[DesignerCategory("code")] [ToolStripItemDesignerAvailability(ToolStripItemDesignerAvailability.ToolStrip | ToolStripItemDesignerAvailability.StatusStrip)] public partial class ToolStripMaskedTextBox : ToolStripControlHost { public MaskedTextBox MaskedTextBox { get { return Control as MaskedTextBox; } } public ToolStripMaskedTextBox() : base(CreateControlInstance()) { } private static Control CreateControlInstance() { MaskedTextBox mtb = new MaskedTextBox(); mtb.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle; mtb.MinimumSize = new System.Drawing.Size(100, 16); mtb.PasswordChar = '*'; return mtb; } } </code></pre> <p>Any help on what I might be doing wrong that's giving the designer a hard time would be appreciated.</p> <p><strong>Addition Info</strong></p> <p>Now when I open my class file in Visual Studio, I get a warning page with the following error:</p> <pre><code>Constructor on type 'System.Windows.Forms.ToolStripControlHost' not found. </code></pre> <p><strong>Addition Info 2</strong></p> <p>The problem only occurs after building the solution. I can get the designer working correctly by modifying the Form.Designer.cs file in even the smallest way. Like adding a single space. From there on out the designer will work fine. That is until I build the solution. Then the designer freezes up again. None of the controls on the form can be edited.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload