Does anyone know where I can find a list of naming conventions for UI elements. I found a bunch of places where they have variable, property, method, event handler, formatting style, etc. conventions. But I am having a hard time finding naming conventions other than the Visual Basic 6.0 Naming Conventions on Microsoft's website.

C# .NET Naming Conventions
Glasgow_Bhoy
Yes. I agree completely with that, its more important have a convention and to follow it consistently than having a specific convention.
Regards,
Vikram
KaroK
class _Description
{
object _DescriptionType;
void _Description(object _descriptiontype)
{
object _DESCRIPTIONTYPE;
}
}
mgjohnston
I've been adapting this behavior for a while now, but now I find myself doing postfixing instead. I name textboxes "thisAndThatTextBox" and strings "thatAndThisString". This isn't much better than doing prefixed notation.
If you want Intellisense to group your object names by type, prefixing is a pretty good thing. The problem with prefixing is that it's originally designed for C, where there were about a dozen or two of built-in types. That made it easy to set unambiguous prefixes (like n for int, c for char, d for double and so on). Now there are thousands of classes... How do you separate prefixes for classes with similar names, or even classes with identical names but that reside in different namespaces
Mazzel
http://www.irritatedvowel.com/Programming/Standards.aspx
Alan Kravanja
As for a single convention that solves all problems, they're not actually intended to solve problems. See my comments in the previous paragraph for their purpose ;)
So while I might disagree with your suggestion that the control type is more important than the data contained by the control (and I do) or that variable names should start with an underscore (which I also do, but case insensitivity makes it a tougher one to hold), ultimately, my opinion doesn't matter. All that matters is the existance of the convention and the strictness to which code is created against that. Which means that FxCop should be part of every developer's toolbox.
dannback
I've actually already looked at that page, unfortunately, it doesn't give me what I'm looking for. Maybe I can explain a little better what I need:
In VB6.0 Microsoft lists prefixes for common control elements:
For example:
Textbox [txt] = txtMyTextBox
Menu [mnu] = mnuFileOpen
etc.
I'm looking for a list comparable to that, more updated than VB6.0, and preferably directed to C#.NET.
Thanks for the link though, it does help for future reference.
Whizman
I tend to use names like:
Label lblDescription;
TextBox txtAge;
Button btnOK;
ComboBox cboInputType;
ListBox lstMembers;
ListView lvwResults;
MenuItem mnuFileOpen;
MaskedTextBox mtxtPhone; // prefix as a TextBox "modifier"
GroupBox grpAddress;
DateTimePicker dtpCurrent;
LinkLabel llblAuthor; // prefix as a Label "modifier"
CheckedListBox clstMovies; // prefix as a ListBox "modifier"
CheckBox chkShowHidden;
RadioButton rbtnPause; // prefix as a RadioButton "modifier"
... well you get the picture :D
For other variables, a very simple prefix system...
I want it to be as little "wordy" as possible, but still not complex like "hungarian" notation.
int iCount;
string sName; // I understand "sz" (string, zero-terminated) would be better because this conflicts with short, but I never really use shorts, just ints or longs so I rarely get into that trouble and "s" is very much more used so it's nice to have a short id for that.
double fValue; // I actually use "f" here, because I never really use the "float" type anyway, and it's more for historical reasons of being used to "f". Maybe bad, but I get across the message it's a floating point value anyway.
long lFileSize;
bool bEnabled;
char chDelimiter; // yes, not "c", no idea why ;)
unsigned int nCount; // the only unsigned I really tend to use, otherwise I guess I'd go for "ulFileSize".
lkd85
Typically, I know what type of control I'm using for UI IO, so having textboxes grouped can help.
Now, all that said, I have switched to naming UI controls like any other class-level object:
txtCustomerNumber becomes "_customerNumber". This leads to some debate as to the naming of business objects. If I also have a class that encapsulates customer numbers, what do I name it I've toyed with the idea of prefixing UI controls e.g. _uiCustomerNumber, but that is a slippery slope back to hungarian. To date, I have not seen a single convention that solves all problems.
Andrew Pardoe
I use the following naming convention
For exsample
TextBox customerCodeTextBox=new TextBox()
Label customerCodeLabel=new Label()
You know guy. Many many control in .net that we cannot convert all to some prefix name. So I choose this naming....easy and fit any new control
hriverag93
Jeff Menninger
Do you really care what type the control is No you care what data the control represents
for example, I want to send the customer number that a user has typed into a text box to a function and I have 10 text boxes on the form. . . .
I had to type:
"Process(txt"
Before Intellisense started to show me what I was looking for, and it would show all the text boxes.
where as
"Process(cus"
shows me the controls that are 'oriented' to the task at hand
howudodat
cathalconnolly
I dont think there is any official document which lists the 3 letter prefixes for all the new controls in .NET. You can create a standard of your own and as long as you document it and use it consistently in your code it should be fine.
For further tips on naming conventions - take a look here:
http://weblogs.asp.net/scottdockendorf/archive/2005/01/26/361020.aspx
Regards,
Vikram
avner ben-zvi
http://msdn.microsoft.com/library/default.asp url=/library/en-us/cpgenref/html/cpconNETFrameworkDesignGuidelines.asp
Hope this helps.