Reputation: 947
I'm a WPF developer and have to perform some task in WinForms (I'm a total newbie of WinForms).
Unlike in WPF, I've noticed that the InitializeComponent method in WinForms is generated by the Windows Form Designer, and obviously I can't modify the code written in this method manually as it might just be overridden upon code regeneration.
Let's say I wish to change the following line in the InitializeComponent of WinForms From:
this.myBtn.ImageAlign = System.Drawing.ContentAlignment.BottomCenter;
To:
this.myBtn.ImageAlign = System.Drawing.ContentAlignment.MiddleCenter;
What is the correct way of doing so? I haven't found any custom code in the codebase that enforces this BottomCenter value? Where is this value coming from? Is it a default value in WinForms?
I've searched the web and encountered similar questions, such as: https://social.msdn.microsoft.com/Forums/en-US/92ab4ea6-c7c8-44cb-91e7-e91c4f77accd/how-to-modify-windows-form-designer-generated-code-in-initializecomponent-method-programmitically?forum=winforms
in which it is suggested to implement a custom CodeDomSerializer on the control. Is it the right approach for doing such a simple thing? I just want to change a simple ImageAlign property.
Upvotes: 1
Views: 586