Tuesday 24 June 2008

CancelButtons and Visual Inheritance

I started writing a new WinForms app yesterday, which is going to be a Wizard. I created a base form to inherit from so that all forms would be the same size, have Next & Previous buttons etc. I also added a button called CancelButton, which has to be marked as Shadows so it doesn't screw up the CancelButton property of the form itself.
However when I tried to create the first form subclassing my base form, I got an 'Ambiguous match found' error in the Visual Studio designer. Couldn't find any obvious solution from Googling (partly why I'm blogging it here), but the solution was to rename the button on the base form to 'MyCancelButton' (or, I suspect, anything but CancelButton). It seems that even if my CancelButton was marked as Shadows, the VB.NET compiler isn't quite cute enough to figure out what's supposed to happen.

No comments: