3 Replies - 2229 Views - Last Post: 03 September 2013 - 06:33 PM Rate Topic: -----

#1 JJ18  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 30-July 13

How can i populate or dynamically create menus in vb.net form?

Posted 03 September 2013 - 10:26 AM

I want to build a menu dynamically by getting the sub-menus from a table in my database
Is This A Good Question/Topic? 0
  • +

Replies To: How can i populate or dynamically create menus in vb.net form?

#2 Michael26  Icon User is online

  • DIC-head, major DIC-head
  • member icon

Reputation: 349
  • View blog
  • Posts: 1,504
  • Joined: 08-April 09

Re: How can i populate or dynamically create menus in vb.net form?

Posted 03 September 2013 - 10:33 AM

It is customary for a person to show some effort before we can help them, aka help us to help you :)
Was This Post Helpful? 0
  • +
  • -

#3 Martyr2  Icon User is offline

  • Programming Theoretician
  • member icon

Reputation: 4316
  • View blog
  • Posts: 12,096
  • Joined: 18-April 07

Re: How can i populate or dynamically create menus in vb.net form?

Posted 03 September 2013 - 11:02 AM

Here is something to get you started. This shows how you build the menu dynamically, the rest is up to you to loop through a dataset, create an ToolStripItem or SubItem using the text values from that dataset.

' Create a menu strip
Dim mainMenu As New MenuStrip

' Create a menu strip item to put on our menu named "example"
Dim item As New ToolStripMenuItem("&Example")

Dim subitem As New ToolStripMenuItem("SubItem 1")

' Lets add a handler to it for when it is clicked
AddHandler subitem.Click, AddressOf SubMenu_onclick

' Add a subitem to it
item.DropDownItems.Add(subitem)

' Add the menu item to the menu and then add the menu to the form.
mainMenu.Items.Add(item)
Me.Controls.Add(mainMenu)



Hope this is what you were looking to do. :)
Was This Post Helpful? 0
  • +
  • -

#4 JJ18  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 7
  • Joined: 30-July 13

Re: How can i populate or dynamically create menus in vb.net form?

Posted 03 September 2013 - 06:33 PM

i have already created the menustrip and now i want to add sub-menu items to it from a dataset...how do i add items dynamically to an already existing menu??
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1