Andy's observations as he continues to attempt to know all that is .NET...

Monday, July 03, 2006

Safety Button

This component grew out of a demo I do whilst teaching ENET for DevelopMentor http://www.develop.com

It demonstrates how to extend WinForms controls to add additional functionality. In this case we are extending the standard button, to provide a means to intercept the Click event and prompt the user are they sure they wish to perform the said action, if they decline the registered event handlers of the button event are non the wiser. Whilst I initially thought this was a trivial demo, it actually turns out that alot of code is written inside Click handlers to throw up a “Are you sure” message. So I’ve done a few enhancements to it over and above what we do in class and provided it as a component to download from my Download page. Whilst building the component I stumbled on a bug in VS Designer, in that I wanted to expose a property of type MessageBoxIcon to allow users of the button to determine what Icon to use in the warning message box.

So I exposed the property as normal but when I came to modify the property in the designer I kept seeing multiple copies of a single enumeration..The issue arises because the MessageBoxIcon enumeration has many Names bound to a single value, this seems to confuse VS. So in order to work around this I created my own enumeration that has no duplicates

No comments:

About Me

My photo
Im a freelance consultant for .NET based technology. My last real job, was at Cisco System were I was a lead architect for Cisco's identity solutions. I arrived at Cisco via aquisition and prior to that worked in small startups. The startup culture is what appeals to me, and thats why I finally left Cisco after seven years.....I now filll my time through a combination of consultancy and teaching for Developmentor...and working on insane startups that nobody with an ounce of sense would look twice at...