Visual Basic

Moderators: None (Apply to moderate this forum)
Number of threads: 17974
Number of posts: 55343

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Creating Menu & Submenus Programmatically Posted by olatundeola on 21 Feb 2003 at 1:15 AM


I want to create menu & sub menu programmatically
on a form. Can anyome Help?

Cheers! !! !!!
Report
Re: Creating Menu & Submenus Programmatically Posted by jeffreyhamby on 21 Feb 2003 at 7:45 AM

: I want to create menu & sub menu programmatically
: on a form. Can anyome Help?
:
: Cheers! !! !!!


Public Sub AddMenuAndItems()
   Dim mnuFileMenu as New MainMenu()
   Dim myMenuItemFile as New MenuItem("&File")
   Dim myMenuItemNew as New MenuItem("&New")
   Dim myMenuItemFolder as New MenuItem("&Options")

   'add menu item
   mnuFileMenu.MenuItems.Add(myMenuItemFile)
   myMenuItemFile.MenuItems.Add(myMenuItemNew)

   'another method
   mnuFileMenu.MenuItems.Add("Save &As")


   'add submenu item
   myMenuItemNew.MenuItems.Add(myMenuItemFolder)


   Me.Menu = mnuFileMenu

End Sub



another example from MSDN
Public Sub CreateMyMenu()
    ' Create a main menu object.
    Dim mainMenu1 As New MainMenu()

    ' Create empty menu item objects.
    Dim menuItem1 As New MenuItem()
    Dim menuItem2 As New MenuItem()

    ' Set the caption of the menu items.
    menuItem1.Text = "&File"
    menuItem2.Text = "&Edit"

    ' Add the menu items to the main menu.
    mainMenu1.MenuItems.Add(menuItem1)
    mainMenu1.MenuItems.Add(menuItem2)

    ' Add functionality to the menu items using the Click event. 
    AddHandler menuItem1.Click, AddressOf Me.menuItem1_Click
    AddHandler menuItem2.Click, AddressOf Me.menuItem2_Click

    ' Assign mainMenu1 to the form.
    Me.Menu = mainMenu1
End Sub 'CreateMyMenu


MSDN article....
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskaddingmenusitemstomenu.asp

Report
Re: Creating Menu & Submenus Programmatically Posted by kel1981b on 21 Feb 2003 at 8:10 AM
:
: : I want to create menu & sub menu programmatically
: : on a form. Can anyome Help?
: :
: : Cheers! !! !!!
:

:
:
: Public Sub AddMenuAndItems()
:    Dim mnuFileMenu as New MainMenu()
:    Dim myMenuItemFile as New MenuItem("&File")
:    Dim myMenuItemNew as New MenuItem("&New")
:    Dim myMenuItemFolder as New MenuItem("&Options")
: 
:    'add menu item
:    mnuFileMenu.MenuItems.Add(myMenuItemFile)
:    myMenuItemFile.MenuItems.Add(myMenuItemNew)
: 
:    'another method
:    mnuFileMenu.MenuItems.Add("Save &As")
: 
: 
:    'add submenu item
:    myMenuItemNew.MenuItems.Add(myMenuItemFolder)
: 
: 
:    Me.Menu = mnuFileMenu
: 
: End Sub
: 
: 

:
: another example from MSDN
:
: Public Sub CreateMyMenu()
:     ' Create a main menu object.
:     Dim mainMenu1 As New MainMenu()
: 
:     ' Create empty menu item objects.
:     Dim menuItem1 As New MenuItem()
:     Dim menuItem2 As New MenuItem()
: 
:     ' Set the caption of the menu items.
:     menuItem1.Text = "&File"
:     menuItem2.Text = "&Edit"
: 
:     ' Add the menu items to the main menu.
:     mainMenu1.MenuItems.Add(menuItem1)
:     mainMenu1.MenuItems.Add(menuItem2)
: 
:     ' Add functionality to the menu items using the Click event. 
:     AddHandler menuItem1.Click, AddressOf Me.menuItem1_Click
:     AddHandler menuItem2.Click, AddressOf Me.menuItem2_Click
: 
:     ' Assign mainMenu1 to the form.
:     Me.Menu = mainMenu1
: End Sub 'CreateMyMenu
: 

:
: MSDN article....
: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskaddingmenusitemstomenu.asp
:
:
Correct me if I am wrong but I think this will work only with VB.NET.
Report
Re: Creating Menu & Submenus Programmatically Posted by jeffreyhamby on 21 Feb 2003 at 8:23 AM

: Correct me if I am wrong but I think this will work only with VB.NET.


Whoops... looks like Kel is right. There doesn't appear to be a way in pre VB.NET that I can find, but you could create all the instances you would need in the menu, then programmatically make them visible or not.
Report
Re: Creating Menu & Submenus Programmatically Posted by olatundeola on 21 Feb 2003 at 9:11 AM
:
: : I want to create menu & sub menu programmatically
: : on a form. Can anyome Help?
: :
: : Cheers! !! !!!
:

:
:
: Public Sub AddMenuAndItems()
:    Dim mnuFileMenu as New MainMenu()
:    Dim myMenuItemFile as New MenuItem("&File")
:    Dim myMenuItemNew as New MenuItem("&New")
:    Dim myMenuItemFolder as New MenuItem("&Options")
: 
:    'add menu item
:    mnuFileMenu.MenuItems.Add(myMenuItemFile)
:    myMenuItemFile.MenuItems.Add(myMenuItemNew)
: 
:    'another method
:    mnuFileMenu.MenuItems.Add("Save &As")
: 
: 
:    'add submenu item
:    myMenuItemNew.MenuItems.Add(myMenuItemFolder)
: 
: 
:    Me.Menu = mnuFileMenu
: 
: End Sub
: 
: 

:
: another example from MSDN
:
: Public Sub CreateMyMenu()
:     ' Create a main menu object.
:     Dim mainMenu1 As New MainMenu()
: 
:     ' Create empty menu item objects.
:     Dim menuItem1 As New MenuItem()
:     Dim menuItem2 As New MenuItem()
: 
:     ' Set the caption of the menu items.
:     menuItem1.Text = "&File"
:     menuItem2.Text = "&Edit"
: 
:     ' Add the menu items to the main menu.
:     mainMenu1.MenuItems.Add(menuItem1)
:     mainMenu1.MenuItems.Add(menuItem2)
: 
:     ' Add functionality to the menu items using the Click event. 
:     AddHandler menuItem1.Click, AddressOf Me.menuItem1_Click
:     AddHandler menuItem2.Click, AddressOf Me.menuItem2_Click
: 
:     ' Assign mainMenu1 to the form.
:     Me.Menu = mainMenu1
: End Sub 'CreateMyMenu
: 

:
: MSDN article....
: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbcon/html/vbtskaddingmenusitemstomenu.asp
:
:

There should be a way out in VB6. What do u guys sugguest.

Report
Re: Creating Menu & Submenus Programmatically Posted by kel1981b on 21 Feb 2003 at 9:27 AM
: I want to create menu & sub menu programmatically
:
What is the reason to do that?
:
Report
Re: Creating Menu & Submenus Programmatically Posted by olatundeola on 24 Feb 2003 at 4:30 AM
Good Day!

I have created a database consisting all menu and submenu items, and i want to select these menus and submenus based on the userid. it is a form of secruity features such that not all user can have access to some menus & sbmenus

Best Regards


: : I want to create menu & sub menu programmatically
: :
: What is the reason to do that?
: :
:



Report
Re: Creating Menu & Submenus Programmatically Posted by kel1981b on 24 Feb 2003 at 5:49 AM
: Good Day!
:
: I have created a database consisting all menu and submenu items, and i want to select these menus and submenus based on the userid. it is a form of secruity features such that not all user can have access to some menus & sbmenus
:
: Best Regards
:
:
: : : I want to create menu & sub menu programmatically
: : :
: : What is the reason to do that?
: : :
: :
:
:
:
:
I think the best way to do that is ceate reqular menu and change property enabled to true or false depending on userid. It's just my ipinion.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.