Losing Data from Designer.Cs File While Opening Form - C# Windows Form Application

Asked

Viewed 43 times

0

I have a custom editor that adds buttons to a collection. This procedure is working well, the data is serialized in the Designer file but when I reopen the form or build the project, the data that was in the Designer disappear.

What before in the Designer file was serialized as:

// 
// MyForm
// 
this.buttons.Add(this.button1);
this.buttons.Add(this.button2);
this.buttons.Add(this.button3);

The auto generated code snippet above disappears at the reopening of the form or when I build the project:

// 
// myForm
// 

Note: Only the variable I have the custom editor.

As far as I can tell, this looks like a disembolarization problem. I have tried to create my own serializer (unsuccessfully), but maybe there could be a simpler solution.

  • Dude, I don’t understand what "deserialization" has to do with it. The problem seems to be that VS rewrites the code of .Designer at certain times.

  • The data of an object is serialized in the designer file to save the "visual state" of that object. When the form is reopened, there is a deserialization to rebuild the object/control, right?! It seems to me that in the reconstruction of the control he may not find how to rebuild this control (because it is customized) or the piece of code previously present in Designer is now not found. But of course, that I may still be wrong, I came for help :)

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.