PC Review


Reply
Thread Tools Rate Thread

Inherited Forms and menus

 
 
Arthur Dent
Guest
Posts: n/a
 
      29th Jun 2006
Hello all,

I have a small application which has a base form, and forms inherited from
it.
The base form contains a barcode scanner, and a protected event it raise
when the scanner reads data, and the inherited forms can get the scanner and
catch the event with no problems at all.

My problem comes in, with a mainMenu which i have on the base form, which i
expected to see show up on the inherited form, however, it doesnt. This was
kind of the whole reason why i wanted to use a base form, was so i wouldnt
have to duplicate the same menu on a bunch of forms, with duplicate code.
Why does the menu not show up, is there a reason? Anyone know how to fix
this?

Thanks in advance,
- Arthur Dent.


 
Reply With Quote
 
 
 
 
=?Utf-8?B?QWxleCBZYWtobmluIFtNVlBd?=
Guest
Posts: n/a
 
      29th Jun 2006
Works for me.

Which version of VS and CF is that?

--
Alex Yakhnin, .NET CF MVP
www.intelliprog.com | www.opennetcf.org


"Arthur Dent" wrote:

> Hello all,
>
> I have a small application which has a base form, and forms inherited from
> it.
> The base form contains a barcode scanner, and a protected event it raise
> when the scanner reads data, and the inherited forms can get the scanner and
> catch the event with no problems at all.
>
> My problem comes in, with a mainMenu which i have on the base form, which i
> expected to see show up on the inherited form, however, it doesnt. This was
> kind of the whole reason why i wanted to use a base form, was so i wouldnt
> have to duplicate the same menu on a bunch of forms, with duplicate code.
> Why does the menu not show up, is there a reason? Anyone know how to fix
> this?
>
> Thanks in advance,
> - Arthur Dent.
>
>
>

 
Reply With Quote
 
Arthur Dent
Guest
Posts: n/a
 
      29th Jun 2006
VS2005, CF2.

The inherited menu does show up in the component tray at the bottom of the
designer in inherited forms, but it just doesnt render itself on to the
form.

"Alex Yakhnin [MVP]" <(E-Mail Removed)> wrote in message
news:36937956-57FD-4663-943D-(E-Mail Removed)...
> Works for me.
>
> Which version of VS and CF is that?
>
> --
> Alex Yakhnin, .NET CF MVP
> www.intelliprog.com | www.opennetcf.org
>
>
> "Arthur Dent" wrote:
>
>> Hello all,
>>
>> I have a small application which has a base form, and forms inherited
>> from
>> it.
>> The base form contains a barcode scanner, and a protected event it raise
>> when the scanner reads data, and the inherited forms can get the scanner
>> and
>> catch the event with no problems at all.
>>
>> My problem comes in, with a mainMenu which i have on the base form, which
>> i
>> expected to see show up on the inherited form, however, it doesnt. This
>> was
>> kind of the whole reason why i wanted to use a base form, was so i
>> wouldnt
>> have to duplicate the same menu on a bunch of forms, with duplicate code.
>> Why does the menu not show up, is there a reason? Anyone know how to fix
>> this?
>>
>> Thanks in advance,
>> - Arthur Dent.
>>
>>
>>



 
Reply With Quote
 
Arthur Dent
Guest
Posts: n/a
 
      29th Jun 2006
Okay, i figured this out....

I dont know *exactly* what was wrong (as far as the code-behinds) but the
problem was something with how the definitions were made.

Originally, id made my first form, then made the master, then tried to
manually code the first form to inherit from the master. Obviously i missed
something.
I added a new form, and chose "inherited form" from the item type list, and
chose the master form when prompted, and now everything is hooked up
beautifully.

Thanks Alex for your help, though.

Cheerz All,
- Arthur Dent.


"Arthur Dent" <hitchhikersguideto-(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hello all,
>
> I have a small application which has a base form, and forms inherited from
> it.
> The base form contains a barcode scanner, and a protected event it raise
> when the scanner reads data, and the inherited forms can get the scanner
> and catch the event with no problems at all.
>
> My problem comes in, with a mainMenu which i have on the base form, which
> i expected to see show up on the inherited form, however, it doesnt. This
> was kind of the whole reason why i wanted to use a base form, was so i
> wouldnt have to duplicate the same menu on a bunch of forms, with
> duplicate code. Why does the menu not show up, is there a reason? Anyone
> know how to fix this?
>
> Thanks in advance,
> - Arthur Dent.
>



 
Reply With Quote
 
New Member
Join Date: Jun 2011
Posts: 1
 
      23rd Jun 2011
I did precisely the same thing that you did:

1) I had a form -- let's call it "Form1" -- with a MainMenu on it.
2) I then created a base form -- let's call it "BaseForm1" -- also with a MainMenu on it.
3) I then changed Form1 so that it inherited from BaseForm1 instead of System.Windows.Forms.Form, by changing its header line "public partial class Form1 : Form" to "public partial class Form1 : BaseForm1".

I then realized that Form1's MainMenu would no longer be necessary, since BaseForm1's MainMenu should show, so I deleted Form1's MainMenu.

I then opened the form designer for Form1, expecting BaseForm1's MainMenu to show... but it didn't.

So I removed the line "this.Menu = null;" from Form1's InitializeComponent() method, and viola! BaseForm1's MainMenu now shows on Form1.
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Inherited Controls and Context Menus Phill W. Microsoft VB .NET 1 9th Oct 2008 08:22 PM
Inherited Forms =?Utf-8?B?RWRC?= Microsoft Dot NET 2 8th Jun 2007 03:46 AM
Inherited Menus and Modifiers =?Utf-8?B?QnV6eg==?= Microsoft Dot NET Framework Forms 6 19th Dec 2005 10:47 PM
Can menus be inherited from base forms under CF 2.0? Debbie Microsoft Dot NET Compact Framework 2 9th Sep 2005 08:22 AM
base forms and inherited forms moondaddy Microsoft Dot NET Framework Forms 10 4th Nov 2004 03:38 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 11:13 AM.