473,545 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically update menustrip and ToolStripMenuIt em

Hi,

I have a dynamically generated MenuStrip following this example:
http://www.codeproject.com/useritems..._MenuStrip.asp

Basically the menu strip allows users to save and load reports. The
Load menu is to list all the saved reports. I need to refresh the
Load menu after a new report is saved. Any help is much appreciated!

Code:
'Generates the MenuStrip, called at Form_OnLoad
Public Sub PopulateMenuStr ip()
Dim mnMenu As New MenuStrip
Dim tsItem As ToolStripMenuIt em
mnMenu.Width = 1095
mnMenu.Height = 24
tsItem = New ToolStripMenuIt em("Save", Nothing, New
System.EventHan dler(AddressOf MainMenuSave_On Click), "tsmiSave")
mnMenu.Items.Ad d(tsItem)
tsItem = New ToolStripMenuIt em("Save as Existing", Nothing,
New System.EventHan dler(AddressOf MainMenuSaveAs_ OnClick),
"tsmiSaveAs ")
UpdateSavedRepo rtList(tsItem)
mnMenu.Items.Ad d(tsItem)
tsItem = New ToolStripMenuIt em("Load", Nothing, New
System.EventHan dler(AddressOf MainMenuLoad_On Click), "tsmiLoad")
UpdateSavedRepo rtList(tsItem)
mnMenu.Items.Ad d(tsItem)
tsItem = New ToolStripMenuIt em("Delete", Nothing, New
System.EventHan dler(AddressOf MainMenuDelete_ OnClick), "tsmiDelete ")
UpdateSavedRepo rtList(tsItem)
mnMenu.Items.Ad d(tsItem)
Me.Controls.Add (mnMenu)
End Sub

'Updates the ToolStripMenuIt em based on data
'Called in above Sub (which is called OnLoad) but would also need to
cal it after anytime some1 saves a new report
'it works when the MenuStrip above is created, but how can I update
the MenuStrip above after the form has loaded
Public Sub UpdateSavedRepo rtList(ByRef sender As Object)
Dim cms As New ContextMenuStri p()
Dim sMenu() As String
Dim i As Integer
Dim sMenuRD As SqlClient.SqlDa taReader

sMenuRD = Blackport.c_Bla ckportData.getS avedFlexiReport s()
If sMenuRD.HasRows Then
ReDim Preserve sMenu(0)
i = 0
While sMenuRD.Read()
ReDim Preserve sMenu(i)
sMenu(i) = sMenuRD("txtRep ortName")
i = i + 1
End While
End If
sMenuRD.Close()

For Each sMn As String In sMenu
cms.Items.Add(s Mn, Nothing, New
System.EventHan dler(AddressOf SelectedChildMe nu_OnClick))
Next
Dim tsi As ToolStripMenuIt em = CType(sender,
ToolStripMenuIt em)
tsi.DropDown = cms
End Sub

Nov 12 '07 #1
0 5028

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
18434
by: ShaneO | last post by:
Probably a stupid question, but I can't seem to find how to Enable/Disable Submenu items within a MenuStrip. File -Open -Save .. ..
12
3159
by: Steve_Black | last post by:
I posted a similar message earlier but we've geared away from the original topic somewhat so I thought I'd post again in hopes of getting input from others. I am creating a MenuStrip dynamically. For each ToolStripMenuItem, I'm adding an event handler so that the same routine gets called regardless of which menu item was clicked. All of...
0
2956
by: genojoe | last post by:
Included below are four methods and a Friend that can be inserted directly into a form that already contains Button1, Button2, and MenuStrip1. Button1 populates the MainMenu control, button2 populates the MenuStrip control. The MainMenu is from legacy 2003 and works fine. I want to upgrade to the MenuStrip but cannot find a way to duplicate...
1
1972
by: genojoe | last post by:
I am converting from MainMenu to MenuStrip And I want to list the hierarchy of a clicked menu item. With the MainMenu, it was easy to do using the parent property of the MenuItem. With the ToolStripMenuItem, it no longer works. To better understand my need, please create a VS form and add a MenuStrip, button and two labels to it with the...
6
34627
by: Luqman | last post by:
How can I dynamically Add menuStrip and its menuItems through code using VB.Net 2005 ? Best Regards, Luqman
3
8530
Atran
by: Atran | last post by:
Hello: I have a MenuStrip in my form, so I add a ToolStripMenuItem to the MenuStrip. The ToolStripMenuItem has a checkBox. ------------------------------------------------------------- Now, The ToolStripMenuItem is checked. I want: When I click The ToolStripMenuItem, The ToolStripMenuItem be unchecked, and when I back again and click The...
3
4828
by: MWS | last post by:
Hello, I'm trying to loop through the app.Config file and add the keys from the app.Config as MenuItems on a MenuStrip. The following line blows up... transToolStripMenuItem.DropDownItems.AddRange(new ToolStripItem { TransMenuItem}); The error that I'm getting is "ArgumentNullExceiption was unhandled"
1
623
by: Tony Johansson | last post by:
Hello! I have a System.Windows.Forms.MenuStrip with some ToolStripMenuItem. One of these ToolStripMenuItem is called saveMemberToolStripMenuItem. This one is defined like this this.saveMemberToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem(); I have also a ContextMenuStrip which is connected to the Form. In the Form C-tor I...
2
2958
by: Brian | last post by:
Hi, I have a menustrip that has 3 main menus and various number of menus below them... I am trying to figure out how i can loop through the main menus and then loop through each one of the main menus to get their items and .text field. Any help.... Brian
0
7473
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7406
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7813
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7431
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7761
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
4949
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3457
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3444
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1888
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.