controls should be declared private

  • Thread starter Thread starter Bob
  • Start date Start date
B

Bob

(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
 
* "Bob said:
(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.
 
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.
 
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
 
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
 
Back
Top