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 / March 2006

Tip: Looking for answers? Try searching our database.

Why Form Designer does not generate properties for controls (only fields)?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
tomj@softhome.net - 28 Mar 2006 12:20 GMT
Form Designer generates only fields for controls.

Form1.Designer.cs:
...
private Button closeButton;
...

Disadvantages:
- if I want to make closeButton protected or public I need to manually
write property(because making field protected or public is not
recommended)
- event handlers for controls does not follow method naming convention
(should use Pascal Casing)
Ex: private void closeButton_Click(object sender, EventArgs e)
- ....

As for me I expect Form Designer to generate something like this:
...
private Button closeButton;

private Button CloseButton
{
 get { return closeButton }
}
...

Why not?
Kevin Spencer - 28 Mar 2006 13:58 GMT
> - if I want to make closeButton protected or public I need to manually
> write property(because making field protected or public is not
> recommended)

Making a Control protected or public by default is a bad idea. The Control
is generally only used by the Form itself. Properties are used to expose
members to other classes. The members are made private fields by default
because that is the most likely and safest thing to do when writing your
code for you. Anything else is poor use of encapsulation.

> - event handlers for controls does not follow method naming convention
> (should use Pascal Casing)
> Ex: private void closeButton_Click(object sender, EventArgs e)
> - ....

An Event Handler is not specifically a Method. It is used as a delegate. As
for how it *should* be cased, that is purely arbitrary. Microsoft has
long-established conventions for code that are employed across the board in
uniform fashion across the enterprise. You may find the following section of
the MSDN Library useful:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/html/c
pconnetframeworkdesignguidelines.asp


Signature

HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

Show me your certification without works,
and I'll show my certification
*by* my works.

> Form Designer generates only fields for controls.
>
[quoted text clipped - 23 lines]
>
> Why not?
tomj@softhome.net - 30 Mar 2006 10:31 GMT
>Making a Control protected or public by default is a bad idea.

And what about forms inheritance?

Some controls in base form should be protected.

What you propose to do?

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.