Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to insert a main menu in a tabcontrol

Status
Not open for further replies.

231166

Programmer
Apr 5, 2005
104
0
0
FR
Hi,

I have created a tabcontrol in a form with two pages.
I would like to insert a main menu inside the first page of this tabcontrol.
Infortunaltely, each time i try to insert a main menu in the tabcontrol i see this main menu inserted
at the top of the form and not at the tabcontrol's top, on its first page.

Could you help me to solve this problem?

Thanks a lot from you.

Regards.

Nathalie
 
Did you try dragging the menu to the tabcontrol? release mouse when tbacontrol's page get focus.

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
I don't think you can do that, it appears that the Main Menu parent control can only be a form.

You can however toggle the main menu visibility based on the selected tabpage by toggling the top level menu items visibility in the tab control's SelectedIndexChanged event.

Assume you tab control is TabControl1 and the main menu is MainMenu1.
Code:
Private Sub TabControl1_SelectedIndexChanged(ByVal sender As Object, _
    ByVal e As System.EventArgs) _
    Handles TabControl1.SelectedIndexChanged
        Dim bln As Boolean = CBool(TabControl1.SelectedIndex = 0)
        For Each mi As MenuItem In Me.MainMenu1.MenuItems
            mi.Visible = bln
        Next
    End Sub

 
>>I don't think you can do that, it appears that the Main Menu parent control can only be a form.

I am able to add a menu on a tab page as I said.

Using VB2005 express.


________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
According to MSDN Library, the Inheritance chain is as follows:
System.Object
System.MarshalByRefObject
System.ComponentModel.Component
System.Windows.Forms.Menu System.Windows.Forms.Control
System.Windows.Forms.MainMenu System.Windows.Forms.TabControl

You can verify this by opening the code to your form. Expand the Region: Windows Form Designer generated code
Perfom a FIND on the name of your main menu (assuming its MainMenu1). The first find is the declaration. Find again, you should see the initialization. Find again, you should see where it adds a range of menu items. Find two more times, If you see a line that says Me.Menu = Me.MainMenu1, it was added to the FORM and not the tab control page.

 
It still be the part form's control collection; but it can be visible on the tab page where you placed.

________________________________________________________
Zameer Abdulla
Help to find Missing people
Sharp acids corrode their own containers.
 
There is an improvement on this issue (add a main manu to a tab control), but on 2.0 framework. Using VB.NET 2005, you are able to drag and drop a main menu cotrol onto a container. This contain can be a form, a tabpage, etc.

Hope this clears things out
 
Just to confirm (.net v1.1), the Form control has a MainMenu Property that is set when you drag'n'drop the MainMenu control. The TabControl or TabPage control doesn't have this property, so you can't add a MainMenu to them...
 
... but I believe there are a number of third party menu controls that can be added to any suitable container control, including a number of free ones - google should help.


Hope this helps.

[vampire][bat]
 
If you are using 2005, then drag and drop a main menu onto the tabpage you want.
 
Hi,

I use visualstudio.net 2003 so i understand it will be difficult fotr me to do this.
How can i don so to insert a mainmenu in a tabcontrol?

I will take in consideration the answer bihgtimmin has given
but if you can advice me , it would be very kind from you, because i fell not well with this situation.
Best regards.

Nathalie
 
I don't think you can do this without extending the standard base class (tabcontrol or tabpage)
 
As I said in my reply on 25 Feb 07 at 18:15, use google. There are many (some free) third party controls that will do exactly what you need.


Hope this helps.

[vampire][bat]
 
Hi and thanks,
Could you tell me what is a third party control?

Perhaps a user control?It is not clear for me.

Thanks again for your help.

Regards.
Nathalie
 
A 'third party' control is a control (open source, freeware or shareware) from a different company than Microsoft.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top