By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,949 Members | 1,554 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,949 IT Pros & Developers. It's quick & easy.

Setting properties at design-time faster than at run-time?

P: n/a
In a .NET Windows app, if I set somehting like the title of the form to
"MyApp" at run-time, will that make the app run slightly slower than if I
had set the title at design-time?

Thanks,
Ron
Oct 7 '06 #1
Share this Question
Share on Google+
7 Replies


P: n/a

Ronald S. Cook wrote:
In a .NET Windows app, if I set somehting like the title of the form to
"MyApp" at run-time, will that make the app run slightly slower than if I
had set the title at design-time?

Thanks,
Ron
Ron,

I don't see how since the designer simply sets the property in code
anyway.

--
Tom Shelton

Oct 7 '06 #2

P: n/a
The designer simply writes the code for you. There
is no real difference.

--
Robbe Morris - 2004-2006 Microsoft MVP C#
I've mapped the database to .NET class properties and methods to
implement an multi-layered object oriented environment for your
data access layer. Thus, you should rarely ever have to type the words
SqlCommand, SqlDataAdapter, or SqlConnection again.
http://www.eggheadcafe.com/articles/..._generator.asp

"Tom Shelton" <to*@mtogden.comwrote in message
news:11*********************@c28g2000cwb.googlegro ups.com...
>
Ronald S. Cook wrote:
>In a .NET Windows app, if I set somehting like the title of the form to
"MyApp" at run-time, will that make the app run slightly slower than if I
had set the title at design-time?

Thanks,
Ron

Ron,

I don't see how since the designer simply sets the property in code
anyway.

--
Tom Shelton

Oct 8 '06 #3

P: n/a

Robbe Morris [C# MVP] wrote:
The designer simply writes the code for you. There
is no real difference.
That is what I was trying to say... Perhaps I was unclear.

--
Tom Shelton

Oct 8 '06 #4

P: n/a
Hi Op.

If you click on the designer generated code on the + in version 1.x or look
in the designer class if you put in top of the Solution Explorer "Show all
files" in the class with the name xx.designer.cs than you see the generated
code. That is mostly better than that you or I would do it by hand.

I thought Tom was pretty clear, but before somebode doubt in that.

:-))))))

Cor
"Tom Shelton" <to*@mtogden.comschreef in bericht
news:11**********************@e3g2000cwe.googlegro ups.com...
>
Robbe Morris [C# MVP] wrote:
>The designer simply writes the code for you. There
is no real difference.

That is what I was trying to say... Perhaps I was unclear.

--
Tom Shelton

Oct 8 '06 #5

P: n/a
There can be a differences to designer and runtime setting of
properties.

If you look at the designer generated code it sometimes wraps
BeginInit() and EndInit() around the setting of a controls properties.
This is so the control can optimise the initialising of properties,
generally by delaying any actions on the property until the EndInit.

Also, setting at run time could be done too late thus causing something
like the title to be drawn twice.

I would recommend using the design time setting if possible.

Tigger
Cor Ligthert [MVP] wrote:
Hi Op.

If you click on the designer generated code on the + in version 1.x or look
in the designer class if you put in top of the Solution Explorer "Show all
files" in the class with the name xx.designer.cs than you see the generated
code. That is mostly better than that you or I would do it by hand.

I thought Tom was pretty clear, but before somebode doubt in that.

:-))))))

Cor
"Tom Shelton" <to*@mtogden.comschreef in bericht
news:11**********************@e3g2000cwe.googlegro ups.com...

Robbe Morris [C# MVP] wrote:
The designer simply writes the code for you. There
is no real difference.
That is what I was trying to say... Perhaps I was unclear.

--
Tom Shelton
Oct 8 '06 #6

P: n/a
Tigger,

Maybe is that your intention, but it can be readed in another way.

The so called design time properties can also be used by code yourself.

Cor

"Tigger" <to**@grunt.tvschreef in bericht
news:11**********************@e3g2000cwe.googlegro ups.com...
There can be a differences to designer and runtime setting of
properties.

If you look at the designer generated code it sometimes wraps
BeginInit() and EndInit() around the setting of a controls properties.
This is so the control can optimise the initialising of properties,
generally by delaying any actions on the property until the EndInit.

Also, setting at run time could be done too late thus causing something
like the title to be drawn twice.

I would recommend using the design time setting if possible.

Tigger
Cor Ligthert [MVP] wrote:
>Hi Op.

If you click on the designer generated code on the + in version 1.x or
look
in the designer class if you put in top of the Solution Explorer "Show
all
files" in the class with the name xx.designer.cs than you see the
generated
code. That is mostly better than that you or I would do it by hand.

I thought Tom was pretty clear, but before somebode doubt in that.

:-))))))

Cor
"Tom Shelton" <to*@mtogden.comschreef in bericht
news:11**********************@e3g2000cwe.googlegr oups.com...
>
Robbe Morris [C# MVP] wrote:
The designer simply writes the code for you. There
is no real difference.
That is what I was trying to say... Perhaps I was unclear.

--
Tom Shelton

Oct 9 '06 #7

P: n/a
Yes,

As you stated, you can see that the designer adds its own code to set
the properties.

And you can do the same. It just might not be as efficient as the code
the designer makes due to the reasons I made. (Don't directly edit the
designer code unless you know what you are doing as there's a good
chance your changes will be lost)

We have come across speed issues in our application due to runtime
setting of properties. Our solution was to follow the pattern used by
the designer and implement and use the IInitializable interface
(BeginInit, EndInit) for our own runtime code.

We also had problems with the gui re-drawing as you change properties,
which can be very slow. These issues can be quite complex to solve at
times.

However, I don't think the Title property is one that will suffer from
any speed issues.

Tigger

Cor Ligthert [MVP] wrote:
Tigger,

Maybe is that your intention, but it can be readed in another way.

The so called design time properties can also be used by code yourself.

Cor

"Tigger" <to**@grunt.tvschreef in bericht
news:11**********************@e3g2000cwe.googlegro ups.com...
There can be a differences to designer and runtime setting of
properties.

If you look at the designer generated code it sometimes wraps
BeginInit() and EndInit() around the setting of a controls properties.
This is so the control can optimise the initialising of properties,
generally by delaying any actions on the property until the EndInit.

Also, setting at run time could be done too late thus causing something
like the title to be drawn twice.

I would recommend using the design time setting if possible.

Tigger
Cor Ligthert [MVP] wrote:
Hi Op.

If you click on the designer generated code on the + in version 1.x or
look
in the designer class if you put in top of the Solution Explorer "Show
all
files" in the class with the name xx.designer.cs than you see the
generated
code. That is mostly better than that you or I would do it by hand.

I thought Tom was pretty clear, but before somebode doubt in that.

:-))))))

Cor
"Tom Shelton" <to*@mtogden.comschreef in bericht
news:11**********************@e3g2000cwe.googlegro ups.com...

Robbe Morris [C# MVP] wrote:
The designer simply writes the code for you. There
is no real difference.


That is what I was trying to say... Perhaps I was unclear.

--
Tom Shelton
Oct 9 '06 #8

This discussion thread is closed

Replies have been disabled for this discussion.