I've read a few articles recently regarding the use of strings with enums - discussing how to access the constant name values or how to set a variable with the correct value when you only have a string value (enum constant name) - and all present somewhat convoluted ways of achieving this. I'm guessing the authors are not aware that the .Net framework provides methods for this - out the box. Hopefully the following code shows how to do this. private enum CarTypes { Lotus = 0, Morgan = 1, Atom = 2 ......
Doing some winforms dev for a change - and had a need to hide a form, instead of closing it, when the user clicked the standard windows close form button (little cross [x] icon on the top right corner of the form). The solution is to create a handler for the FormClosing event of the form, then force the form to be hidden, then, the important part, cancel the close event... Eg: // Use this event handler for the FormClosing event. private void MyForm_FormClosing(object sender, FormClosingEventArgs ......