The problem is I've already initialized all the initial values for my Properties in my Custom control constructor, for example, PropA = true. But when dragging-n-dropping the final Custom control onto a form, there are some values which are changed to different values (E.g: PropA = false).
I can understand why that happens, that's because of the auto-generated code which do very redundant works. I mean, only properties changed by us (programmers) in the properties window should be added with auto-generated code in the designer.cs files. Why does it have to add redundant code (and sometimes, unwanted code as in my case) to the designer.cs file. Here is the flow of code executing order which makes my default values go away:
public Form(){
//I replace the InitializeComponent() method by its content right in here
myCustomControl = new MyCustomControl(); <---- everything is already
//set up OK at here, no need auto-generated code for my custom properties.
SuspendLayout();
/////Initialize properties
//My custom properties go here, they are already set to default values in my
//custom control constructor (the line right at the very top above).
//And that means, all the auto-generated code below are preparing to erase
//all those default values unexpectedly.
myCustomControl.PropA = false; //While, PropA is already set to true
//in MyCustomControl() constructor and what I want is it should be true, not false
//but the designer doesn't understand me or I have to understand it????
//The same for other custom properties of mine
....
....
ResumeLayout(false);
PerformLayout();
}
I would like to know how to understand the designer or how to make it understand me???
Your help would be highly appreciated!
Thank you in advance!