Inherits broken in VB 2.0?

  • Thread starter Thread starter Gregory Gadow
  • Start date Start date
G

Gregory Gadow

I am looking to create a custom TabControl in VB using VS 2.0. All of
the documentation I've found online starts with

Public Class NewTabControl
Inherits Windows.Forms.TabControl

End Class

But when I try that, I get the following error message:

"Base class 'System.Windows.Forms.TabControl' specified for class
'NewTabControl' cannot be different from the base class
'System.Windows.Forms.UserControl' of one of its other partial types."

I am starting my new control with a User Control, which seems to be the
problem; starting with a Class file works fine. But I'm not sure how to
attach a designer component to a Class, which would allow me to add some
custom drawn items, such as a "close" button on the tab. Any suggestions
on how to subclass a standard control?
 
Nothing is broken.

When you create a user control, VS creates a .Designer file that contains
all the designer generated code. In there it says that the class inherits
from UserControl. So there is your conflict.

If you start off with just a class file, try restarting VS after you change
it to inherit from TabControl. That may help in giving the designer surface.
 
In the solution provider click on the "Show All files button"
then in the <ClassName>.Designer.vb file change the
Inherits Windows.Forms.UserControl
to
Inherits Windows.Forms.TabControl

Regards
Neal
 
Gregory Gadow said:
I am looking to create a custom TabControl in VB using VS 2.0. All of
the documentation I've found online starts with

Public Class NewTabControl
Inherits Windows.Forms.TabControl

End Class

But when I try that, I get the following error message:

"Base class 'System.Windows.Forms.TabControl' specified for class
'NewTabControl' cannot be different from the base class
'System.Windows.Forms.UserControl' of one of its other partial types."

Select the "Show all files" button in the solution explorer. You'll see
that the file "NewTabControl.vb" has a companion file named
"NewTabControl.Designer.vb". In order to make your code compile, change the
'Inherits' line in this file too.
I am starting my new control with a User Control, which seems to be the
problem; starting with a Class file works fine. But I'm not sure how to
attach a designer component to a Class, which would allow me to add some
custom drawn items, such as a "close" button on the tab. Any suggestions
on how to subclass a standard control?

IIRC there is no way to edit a tabcontrol in its own designer the way this
is supported for user controls.
 
Back
Top