2

I am trying to create a program that has multiple layers of controls all drawing on top of each other. The way I'm doing this is that I have a windows.forms.panel that is a container for the panels doing the actual drawing (this way I can layer them).

For the panels doing the drawing I have an abstract class that inherits from windows.forms.panel (call it abstractPanel) that I have set the docking style to "fill". It overrides the onPaint function in which it calls an abstract function that I override in the children.

The problem I have is that when I add a control that inherits from abstractPanel to the container it isn't showing up (the onPaint function isn't being called).

Any suggestions?

Am I thinking about this too much from a Java perspective and need to make abstractPanel not abstract?

R. Martinho Fernandes
  • 228,013
  • 71
  • 433
  • 510
simpleCoder
  • 152
  • 2
  • 13
  • 1
    What difference could it make abstractPanel being abstract? Did you override `onPaint` or `OnPaint`? Maybe you didn't actually override it (unlike Java, C# requires explicitly using the keyword `override`)? – R. Martinho Fernandes Apr 30 '11 at 22:59
  • I am using the function generated by the designer for responding to the paint event in the abstract class. – simpleCoder Apr 30 '11 at 23:44

1 Answers1

1

I've had a similar issue with the Visual Studio WinForms designer: if a form inherits from an abstract class, it doesn't get shown in the designer at all. I don't know why, but for some reason Windows Forms doesn't "like" abstract classes. Try removing the abstract keyword, it won't change the functionality if you do.

Ilya Kogan
  • 21,995
  • 15
  • 85
  • 141
  • @ilya-kogan For clarification I've done all of the designer stuff in the abstract class (i.e. setting it to fill, setting it to auto-resize, etc.) and want that same functionality to occur in the classes inheriting from it. I suppose I don't *need* the abstract keyword, though it does make things cleaner. – simpleCoder Apr 30 '11 at 23:46