Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / Design Time / September 2007

Tip: Looking for answers? Try searching our database.

Where does the designer code come from?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
schneider - 09 Jul 2007 20:00 GMT
How does the designer determine what code is used in the form designer code?

For example 1, when you drag a control (using the object name?):

private System.Windows.Forms.TextBox txtUserName;

this.txtUserName = new System.Windows.Forms.TextBox();

Thanks,
Schneider
OD - 15 Jul 2007 13:28 GMT
> How does the designer determine what code is used in the form designer code?
> For example 1, when you drag a control (using the object name?):
> private System.Windows.Forms.TextBox txtUserName;
> this.txtUserName = new System.Windows.Forms.TextBox();

When you drag a component onto the designer surface, VS is knowing the
class, then using reflection, it can get the list of public properties
and events. As all components must implement IComponent (providing
functionnality required by all components) and must inherit from
Control, it is easy to generate the "new" code and to manage other
common component behaviors.

Nothing really magic, just object programming :-)

Signature

OD___
www.e-naxos.com

schneider - 17 Jul 2007 03:54 GMT
Yes, I guess I should have said "What .NET objects are used to generate the
code?" I want to alter the behavior.

Thanks,
Schneider

>> How does the designer determine what code is used in the form designer
>> code?
[quoted text clipped - 10 lines]
>
> Nothing really magic, just object programming :-)
OD - 17 Jul 2007 13:23 GMT
> Yes, I guess I should have said "What .NET objects are used to generate the
> code?" I want to alter the behavior.

The way code is generated mostly depends on the component itself.
For example, attributes such as Description, Browsable, default values,
default event, etc, are used in component source code and help VS to
display properties, to generate default event when you double-click the
component under design, etc.. Changing this attributes will change the
component behavior under design.

But can you be more precise about what you're wanting to do, give a
little sample if possible. I'm not sure to fully understand your goal.

Signature

OD___
www.e-naxos.com

schneider - 17 Jul 2007 15:35 GMT
I'm looking for what classes are used in creating the code.

Some X object/s must look at the component and decide what to generate code
for and what to ignore or decide where the code should be or look like.

There is also something that decides to put code into different
methods/regions, and creat comments like below.
I'm looking for info on how all this is done.

Thanks,
Schneider
#region Windows Form Designer generated code

/// <summary>

/// Required method for Designer support - do not modify

/// the contents of this method with the code editor.

/// </summary>

private void InitializeComponent() {

>> Yes, I guess I should have said "What .NET objects are used to generate
>> the code?" I want to alter the behavior.
[quoted text clipped - 8 lines]
> But can you be more precise about what you're wanting to do, give a little
> sample if possible. I'm not sure to fully understand your goal.
OD - 17 Jul 2007 21:15 GMT
> I'm looking for what classes are used in creating the code.

Generating the code is the VS job. There is no framework class for this
task. VS does it just by inspecting the class of the component and
taking into account all the supported attributes.
The way VS generate the code by separating some parts (design), etc, is
the specific job of the application "Visual Studio". Rules are changing
from one version to another (VS 2005 doesnt generate the same code than
VS 2003 for example).
You can write a code that performs the same task just using reflection,
but the way the code is finally "rendered" will be precisely your
application job, as VS does it its own way.

Signature

OD___
www.e-naxos.com

Sigurbjörn Valdimarsson - 20 Sep 2007 16:48 GMT
You might want to look at CodeDomSerializer and the
DesignerSerializerAttribute.

> Yes, I guess I should have said "What .NET objects are used to generate
> the code?" I want to alter the behavior.
[quoted text clipped - 16 lines]
>>
>> Nothing really magic, just object programming :-)
schneider - 20 Sep 2007 17:08 GMT
Thanks, that's what I was looking for. Looking to improve the designer code
for my components.

Schneider

> You might want to look at CodeDomSerializer and the
> DesignerSerializerAttribute.
[quoted text clipped - 19 lines]
>>>
>>> Nothing really magic, just object programming :-)

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.