Geeks With Blogs

Tim Huffam Dotting the I and crossing the T of I.T. September 2007 Entries
Using strings and enum - C# .NET
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 ......

Posted On Tuesday, September 18, 2007 3:47 AM

How to hide a form instead of closing it - with C# .Net
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 ......

Posted On Thursday, September 13, 2007 4:37 AM

Copyright © Tim Huffam | Powered by: