Introduction
If you derive a class from Component
, then Visual Studio assumes it's a UI element. Unfortunately, PrintDocument
is derived from Component
- and isn't visual at all, it just uses graphics to draw onto output contexts. But your class counts as a visual element as well despite having no UI, so VS will open it in the design view.
Which promptly brings up a blank screen and invites you to add UI elements to it. :sigh:
To Fix It Is Simple
Just add an attribute to your class definition:
[System.ComponentModel.DesignerCategory("Code")]
public class MyPrinter : PrintDocument
Now VS will put the icon back to normal, and open in the code view.
History