Designers and Abstract Classes

J

Joey Callisay

Brian Pepin has an interesting article at
http://www.urbanpotato.net/Default.aspx/document/970.

The Visual Studio designer works by actually creating instances of objects
on your form. If you have a form with two buttons and a text box, for
example, the form designer creates two real buttons and a real text box. The
one thing the designer cannot create, however, is an instance of your form.
Why? Because you're currently designing it, and it isn't compiled. Instead,
the form designer creates an instance of your form's base class. If you're
just inheriting from Form, that's what gets created. If you're inheriting
from "MyBaseForm", it creates an instance of that. Once the base form
instance is created, the form designer interprets all the code within the
InitializeComponent method to create the other controls on the form.

The line "interprets all the code within the InitializeComponent method"
boggles me. How does VS know the settings in the InitializeComponent if it
never executes these lines at design time. Does anyone here know how this
interpretation is done?
 
H

Herfried K. Wagner [MVP]

* "Joey Callisay said:
The line "interprets all the code within the InitializeComponent method"
boggles me. How does VS know the settings in the InitializeComponent if it
never executes these lines at design time. Does anyone here know how this
interpretation is done?

VS creates the code using CodeDom, so it's also able to "interpret" this
code.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top