Thursday, May 21, 2009

Inheritance of forms in VB .NET

In an earlier post, I talked about form to form navigation. An earlier version of this attempt tried to use in the built-in Form inheritance, which didn't work very well.

The form to form navigation worked fine, but I still had a hankering for some form of inheritance as I found myself creating many variants of forms for entering e.g. a booking field, a container field, etc. (the application is designed to be on a touch screen, for unsophisticated users, so buttons are big and each form is used to enter just 1 field).

I seem to have come up with an alternate solution. The solution is to create a parallel hierarchy of classes of controllers, associated with a form, that do the control. These classes have none of the VB behind-code associated complexity, so inheritance works as expected without unexpected sideeffets.

So far I've created a FormController at the top of the hierarchy, with a TextFormController beneath that, and a specific BookingFormController. The VB Design class is associated with the TextFormController, and the BookingFormController overrides that class to instantiate the heading and to override the save/restore next/back button navigation.

This new idea seems to be working well, and I'll probably eviscerate the code and post the skeleton classes a bit later.

No comments:

Post a Comment