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 / WinForm General / September 2004

Tip: Looking for answers? Try searching our database.

controls should be declared private

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Bob - 13 Sep 2004 18:36 GMT
(IMHO) I think it's poor design to directly refer to a form's controls
outside of the form itself. Having to browse through all of them in
intellisense is also annoying. Is there an IDE option that changes the form
designer's default control declaration to Private instead of Friend? If not,
would anyone else agree that this should be an option?

Bob
Herfried K. Wagner [MVP] - 13 Sep 2004 19:37 GMT
* "Bob" <noone@nowhere.com> scripsit:
> (IMHO) I think it's poor design to directly refer to a form's controls
> outside of the form itself. Having to browse through all of them in
> intellisense is also annoying. Is there an IDE option that changes the form
> designer's default control declaration to Private instead of Friend? If not,
> would anyone else agree that this should be an option?

AFAIK, the modifier used depends on the programming language you are
using.

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/

Imran Koradia - 13 Sep 2004 19:55 GMT
Indeed - the default access modifier for controls in VB .NET is Friend while
in C# it's Private. AFAIK, there's no such option to change the default
access modifier. So you might want to look into developing in C# ;-)

Imran.

> (IMHO) I think it's poor design to directly refer to a form's controls
> outside of the form itself. Having to browse through all of them in
[quoted text clipped - 3 lines]
>
> Bob
Bob - 13 Sep 2004 21:05 GMT
Take away the case sensitivity and I might consider it. That, too, is an
example of a squandered opportunity to clean up bad design in the name of
"backward compatability".

Bob

> Indeed - the default access modifier for controls in VB .NET is Friend while
> in C# it's Private. AFAIK, there's no such option to change the default
[quoted text clipped - 11 lines]
> >
> > Bob
Jason - 16 Sep 2004 15:19 GMT
I agree controls should not be Friend. I personally set some to Private
but most of them to Protected as I add them. I use Protected because I
use visual inheritence quite often and need to tweak some of the base
control. Regardless of each person's preference the default should be
configurable and I'd imagine you might be able to whip up an IDE
extension to change the access modifier whenever a control is dropped
onto a form. I haven't investigated IDE extensibility yet so don't ask
me how to do it.

In the VS2005 beta, the form designer supports controls that exist even
without a member variable at all. The InitializeComponent procedure
creates the variable with local scope, sets the properties, hooks the
event handlers, then forgets. I really don't need Label1 thru Label37
accessible from my code or cluttering the Intellisense.

- Jason

> (IMHO) I think it's poor design to directly refer to a form's controls
> outside of the form itself. Having to browse through all of them in
[quoted text clipped - 3 lines]
>
> Bob

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.