Hello, I have a little coding style problem - what names should I choose for controls in Windows Forms in my application? I think that best approach is to not generate the field at all (GenerateMember
property), this can work at buttons, separators, menu items etc.
But there are for example some labels and controls that I need to reference, modify, disable, etc. from the code. Currently I name them this way: lblInfo
(label) , cbPerson
(combobox), btnOK - I think this is useful use of Hungarian notation. Their names start in lowercase because they are form's fields.
I choose names for the menu items depending on their hierarchy - so it's menuFileExit, menuEditCopy, etc.
The problem comes when I create event handler for one of controls - Visual Studio autogenerates handler such as:
btnOk_Click
, menuEditCopy_Click
- and StyleCop and I don't like no methods that start with lowercase. I also wouldn't like the event handlers to have different prefix than the name of the control that raises the event. Should I just name the event handlers like BtnOk_Click
with first letter in uppercase to satisfy the coding standard? Thanks