Form Controls Naming Standards

  • Thread starter Thread starter Bill Gower
  • Start date Start date
B

Bill Gower

Having come from a VB6 background I liked to prefix all my control names
with txt, cmd, btn etc. What is the accepted standard for Windows forms
controls. I have been looking and looking for MS standards and can't find
any.

Bill
 
Here's something you can peruse.

http://dotnet.mvps.org/dotnet/faqs/?id=namingconventions&lang=en

Basically, Hungarian Notation has gone by the wayside, even in Windows
Forms as of the most current version of VS. All the code I've seen from
Microsofties in the past year uses a standard with the name of the control
as a suffix, like LastNameTextBox, FirstNameComboBox, etc. Kind of
long-winded, but there it is. Of course, there's no law saying which way
you have to go.

If you look on MSDN, search for "naming conventions" or "design guidelines"
or something like that, some of the articles for .Net 1.1 still use
Hungarian Notation in the naming of the controls.

So some people still use Hungarian when naming their controls and forms,
some don't.

Definitely don't do it in your classes and internal code, though, like
strLastName. That's definitely not done any more.

Robin S.
Ts'i mahnu uterna ot twan ot geifur hingts uto.
 
Bill Gower said:
Having come from a VB6 background I liked to prefix all my control names
with txt, cmd, btn etc. What is the accepted standard for Windows forms
controls. I have been looking and looking for MS standards and can't find
any.


In addition to the other reply:

Personally I have adopted the convention to choose names like '<type
name><descriptor>' (e.g. 'TextBoxUserName', 'ButtonCancel', ...). This
allows easy access in IntelliSense.
 
Back
Top