Forgive me if I'm not posting to correct standards, but here is my question. I am using VS2017, C# Winforms development. I created a User Control that is simply just a Text Box. I'm capturing some events in this textbox and changing colors based on things happening, like entry/leave, and read only modes. Yesterday, as I was designing my forms everything was all fine and dandy. Today, I come back to my machine and now I cannot open the designer. I receive an error that says "The Designer cannot process the code at line 470, please see the Task List for details. The code within the method 'InitializeComponent' is generated by the designer and should not be manually modified. Please remove any changes and try opening the designer again."
Here is the designer code it says is causing the issue
this.txtName.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.txtName.BackColor = System.Drawing.Color.Transparent;
this.txtName.Location = new System.Drawing.Point(139, 23);
this.txtName.Name = "txtName";
this.txtName.PasswordChar = "\0";
this.txtName.ReadOnly = false;
this.txtName.Size = new System.Drawing.Size(303, 19);
this.txtName.TabIndex = 2;
Here is the code for my UserControl
public partial class TextBoxCustom : UserControl
{
Color onEnter = Color.Beige;
private Color readOnly = Color.Silver;
Color onLeave = Color.White;
public string Text
{
get
{
return textBox1.Text;
}
set
{
textBox1.Text = value;
}
}
public string Name
{
get { return textBox1.Name;}
set { textBox1.Name = value; }
}
public bool ReadOnly
{
get { return textBox1.ReadOnly; }
set
{
textBox1.ReadOnly = value;
if (value == true)
{
textBox1.BackColor = readOnly;
}
}
}
public string PasswordChar
{
get { return textBox1.PasswordChar.ToString(); }
set { textBox1.PasswordChar = Convert.ToChar(value); }
}
public void Clear()
{
Text = "";
}
public TextBoxCustom()
{
InitializeComponent();
}
private void TextBoxCustom_Leave(object sender, EventArgs e)
{
textBox1.BackColor = (textBox1.ReadOnly) ? readOnly : onLeave;
}
public void SetDataBindings(BindingSource source,string model)
{
textBox1.DataBindings.Add(new Binding("Text", source, model, true, DataSourceUpdateMode.OnPropertyChanged));
}
private void TextBoxCustom_Enter(object sender, EventArgs e)
{
textBox1.BackColor = (textBox1.ReadOnly)? readOnly: onEnter;
}
}
Now, if I were to comment out line 470 like it says, I would receive an error on a different line. I've also commented out the whole block of designer code, and been able to open the designer, but the code just regenerates and throws the error again when I try and go back into it. I've tried cleaning/rebuilding/restarting visual studio. I've deleted the Bin and Obj folders, I've even made sure the UserControl is part of it's own separate project being referenced in the main app.
Thank you in advance for any help.
obj
andbin
directories)? – Daithis.txtName.PasswordChar = "\0";
produces a "String must be exactly one character long." message on my machine. – LarsTech