Visual Studio stores the absurd default value in the constructor file

I have a simple user control with the following properties:

public partial class RichTextEditorControl : UserControl
{

    public string EditorText
    {
        get { return richTextBox1.Rtf; }
        set { richTextBox1.Rtf = value; }
    }

    public string EditorPlainText
    {
        get { return richTextBox1.Text; }
        set { richTextBox1.Text = value; }
    }
}

Now, when I edit the form containing this control, VS fills my constructor file with the following line of code, and then throws a constructor error:

this.richTextEditorControl1.EditorPlainText = 
   global::Project.Resources.MyResources_de_DE.SomeString;

Now I do not know where he gets this value from? I was looking for a whole solution and did not mention this var anywhere except 1 file where it is needed ...

In addition, the VS code writes, has an error in it ?! It does not compile ... The only thing I can do is edit the constructor file, but the next time I need to edit the form with the designer, the same error will happen again ...

 Error  25  The type or namespace name 'MyResources_de_DE' does not exist   
 in the namespace 'Project.Resources' (are you missing an assembly reference?)  

Where on Earth is VS getting this value from

+3
3

, , usercontrol ( ), , , usercontrol, . . , , :

 <System.ComponentModel.DefaultValue("")> public string EditorPlainText ...

. .

, , , "control", , () , Null:

 <System.ComponentModel.DefaultValue(GetType(Control), Nothing)> etc...

, , , ( , , , ) - , "MyUserControl.UselessProperty = Nothing".

.

+1

RTF . , , - , . - - Windows Forms.

Anyhoo, EditorText . EditorPlainText. RTF . , . , , . :

    [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
    public string EditorText {
      // etc..
    }

.

+3

?

.

+1

Source: https://habr.com/ru/post/1749018/


All Articles