C # does not write lines:

this.button1.Click += new System.EventHandler(this.button1_Click); this.textBox1.TextChanged += new System.EventHandler(this.textBox1_TextChanged); this.textBox1.KeyPress += new System.Windows.Forms.KeyPressEventHandler(this.textBox1_KeyPress); 

in Form1.designer.cs. It is necessary to record manually.

  • @ Mr-Al; To format a code, select it with the mouse and click on the editor button 101010. - Nicolas Chabanovsky

2 answers 2

It looks like something falls inside the designer when saved.

The reasons may be as follows.

  • You use paid components without a license or high-quality crack
  • You use components with incorrect settings (for example, in the DevExpress settings there is a checkmark "Allow visual inheritance", without which inherited components do not save changes made to them in inherited classes).
  • You use your components, which in the right places are not worth checking for DesignMode, as a result of which they climb where there is no access from the designer.
  • Sometimes there are problems with too much nesting of controls. Most often they occur when working with splitters (I do not know why, just such a buggy thing).

    I honestly did not understand how you did it. You can create an event programmatically, then in form1.cs (not in the designer) you should write something like this:

     button1.Click += (s, e) => { throw new NotImplementedException(); // тут что-то делаете }; 

    Please explain what you specifically did, that you did not have EventHandlers. And the designer does not touch at all, otherwise every time you will be there to re-write everything. :)