It may look like your favorite programming language, but InitializeComponent is actually the serialized form of the object model that the Designer is using to manage the design surface. Although you can make minor changes to this code, such as changing the Text property on the new button, major changes are likely to be ignored—or worse, thrown away. Feel free to experiment with just how far you can go by modifying this serialization format by hand, but don't be surprised when your work is lost. I recommend putting custom form initialization into the form's constructor, after the call to InitializeComponent, giving you confidence that your code will be safe from the Designer. Of course, we put up with the transgression of the Designer because of the benefits it provides. For example, instead of writing lines of code to set properties on the form or the controls contained therein, all you have to do is to right-click on the object of interest and choose Properties (or press F4) to bring up the Property Browser for the selected object, as shown in
Thursday, October 15, 2020
Subscribe to:
Post Comments (Atom)
Application Settings As some applications get more sophisticated, users expect more from all their applications. For example, some applicat...
-
Before we start the drag-and-drop extravaganza that the Designer enables, let's take a look at a slightly abbreviated version of the co...
-
In the Designer, you can drop and arrange any controls on the user control that you like, setting their properties and handling events jus...
-
Setting the Dock Property As an example, the form in shows the Dock properties for a status bar, a tree view, and a list view, the lat...
No comments:
Post a Comment