Posted on 2005-03-14
I am a bit stumped on how to use inheritance to solve my problem. I am using a non-MDI interface main form that creates and displays user controls (rather than new forms) to display data to the user for browsing and editing. I have a base class called ViewPane. All viewpanes will have a grid style list control and a dataset, however they will each naturally have different schemas. Most of the methods of the viewpane are generic in that they apply to every viewpane such as navigating records and reacting to application events such as cut and paste. Some of the methods apply to all instances but are implemented in different ways such as updating records. I have the concept of overrides somewhat down, but it will not let me override an object declaration on the base class.
I tried to add an untyped dataset and an unbound grid to my base, but I couldnt modify these in the inherited controls. I then tried to add a new strongly typed dataset and bound grid with the same names as the base class controls to the inherited control using the Shadows keyword and this didnt have the results I expected. Mostly got "Object reference not set to an instance..." errors. As I write this it occurs to me that maybe I should be trying to modify the dataset and grid in code at run time rather than in the designer at design time??
I don't want to rewrite code to manage all these grids and datasets on each user control that is identical just because the grids and datasets are not indentical. Help!