I'm trying to use the System.ComponentModel.DesignerCategory Attribtue to prevent an extended Tab Page componenet from automatically opening up in the designer. The suggestions on other StackOverflow questions 1,2,3, don't seem to work.

Here's the code on the component

<!-- language: lang-vb -->
<System.ComponentModel.DesignerCategory("Code")>
Public Class ExtendedTabPage : Inherits Windows.Forms.TabPage

Here's the code in my .vbproj file

<!-- language: lang-xml -->
<Compile Include="ExtendedTabPage.vb">
  <SubType>Component</SubType>
</Compile>

I've tried initializaing the DesignerCategory Attribute with a "" and also "Code", doing rebuilds and reopening the solution, but I still get the screen below from a double click on the component. Do I have to remove the project SubType? Will that affect the way the code compiles?

Component Designer

That window is a pita but there isn't anything you can do to stop it from showing up.

Note how the original TabPage control doesn't show up in the toolbox, it is only ever added by the custom designer for TabControl. This is done by giving it the [ToolboxItem(false)] attribute. And your nemesis, [Designer] attributes that select custom designers for both the TabControl and the TabPage classes. You'd have to create your own ExtendedTabControl and make a designer for it. This is not fun, the TabControlDesigner class is a rather elaborate designer. It is also internal so you cannot derive from it. Using a decompiler like Reflector or ILSpy is a way to peek at the code in those designers. I cannot recommend this unless you have a large and demanding user base of picky paying programmers.

Writing code instead of trying to make this work at design time is feasible. But do note that you have to TryCast() at runtime to convert the TabPage reference you get from the TabPages property to your derived class.