5 Replies - 6856 Views - Last Post: 20 May 2012 - 05:34 PM Rate Topic: -----

#1 elvir22  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 05-March 09

Form Inheritance

Posted 15 April 2010 - 09:21 AM

I have put this code in the global form

Inherits System.Windows.Forms.Form


And then in the form that will inherit this from the global

Inherits MenuStrip


"MenuStrip" is what the global form is called. But keep getting this error

Error 1 Base class 'MenuStrip' specified for class 'Lesson2' cannot be different from the base class 'System.Windows.Forms.Form' of one of its other partial types.


How do i fix this/?

Is This A Good Question/Topic? 0
  • +

Replies To: Form Inheritance

#2 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1057
  • View blog
  • Posts: 4,100
  • Joined: 02-July 08

Re: Form Inheritance

Posted 15 April 2010 - 09:32 AM

If you looked at the designer generated code you will have notice all your form class have that first inheritance statement. And just as your error states you cannot inherit from more than one type - the class cannot be a form and a menustrip. What are you trying to do.
Was This Post Helpful? 0
  • +
  • -

#3 elvir22  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 05-March 09

Re: Form Inheritance

Posted 15 April 2010 - 09:40 AM

Basically im trying to create a global/main form with everything that i need on it which is menustrip, media player and listbox and then inherit it for every other form. Its for a virtual learning environment so all the lessons are the same from lesson 1 to 7
Was This Post Helpful? 0
  • +
  • -

#4 _HAWK_  Icon User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1057
  • View blog
  • Posts: 4,100
  • Joined: 02-July 08

Re: Form Inheritance

Posted 15 April 2010 - 09:44 AM

Then your talking about Visual Inheritance. Here is a tutorial!
Was This Post Helpful? 0
  • +
  • -

#5 elvir22  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 20
  • Joined: 05-March 09

Re: Form Inheritance

Posted 15 April 2010 - 09:58 AM

When i get inherited form up. it wont let me pick MenuStrip, it just lists all the other forms but no that one that i need :(

This post has been edited by elvir22: 15 April 2010 - 10:17 AM

Was This Post Helpful? 0
  • +
  • -

#6 HermanSchoenfeld  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 20-May 12

Re: Form Inheritance

Posted 20 May 2012 - 05:34 PM

View Postelvir22, on 15 April 2010 - 09:58 AM, said:

When i get inherited form up. it wont let me pick MenuStrip, it just lists all the other forms but no that one that i need :(


Microsoft have locked down Visual Inheritance for complex controls because they couldn't figure out how to manage the designer-serialization of child item controls over an inheritance tree in a simple way.

A simple workaround (which achieves the same effect) is to drop an invisible toolstrip on the sub-form and merge it with the base-forms toolstrip at load time.

I've developed MergableToolStrip controls you can use free of charge here - Visual Inheritance for MenuStrip, ToolBarStrip, and StatusStrip Controls.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1