Home Posts Topics Members FAQ
robertybob
116 New Member
Hi,
I am trying to dynamically build up a menustrip at runtime from data in a string such as ...
Item1~Item2~Ite m3~Item4
where each item needs to be a subitem of the previous one in the menu.
I can convert the string to an array, loop through the items and get the data required.
However, I want to be able to efficiently add the sub items to their parent without continually looping through all the item names in the entire menu to see if and where the item already exists.
I know the following code will work but it has to be wildly inefficient when dealing with alot of entries as it looks through the entire menu system each time.
Expand|Select|Wrap|Line Numbers
- Forj=0TomyArray.Count-1
- Dimthisid=myArray(j)
- Dimitemfound=0
- DimadditemAsNewToolStripMenuItem()With{.Text=itemid,.Name=j}
- ForEachmenuitemAsToolStripDropDownItemInmainMenu.DropDownItems
- Ifmenuitem.Name=jThen
- menuitem.DropDownItems.Add(additem)
- itemfound=1
- ExitFor
- EndIf
- Next
- 'ifnotfoundthenaddit...etc
I would have thought a better way is to only look at the items in Item1 when adding Item2 (if no match then add it), then only look at items in Item2 for Item3 etc.
What I can't (yet again) work out is how to change the ForEach line to target the check for existing items in the previous item only. That is...
For Each menuitem As ToolStripDropDo wnItem In <PREVITEM>.Drop DownItems
where <PREVITEM> is Item2 when looking to add Item3.
Does this make any sense at all? :)
Thanks
Mar 15 '13 #1
Subscribe Reply
2 2294
robertybob 116 New Member
Actually, typing this out might have helped :)
Am currently trying DirectCast(main Menu.Items(prev item), ToolStripDropDo wnItem).DropDow nItems to see it thats it.
Will let you know it solved
Mar 15 '13 #2
reply
robertybob 116 New Member
Ok I have isolated this problem to being able to dynamically determine the parent item.
So for the first item added I can use
Expand|Select|Wrap|Line Numbers
- ForEachsubitemAsToolStripDropDownItemInDirectCast(mainMenu.Items(Item1),ToolStripDropDownItem).DropDownItems
For the next one I need to alter 'mainMenu.Items ' to 'Item1.DropDown Items' and so on...
Not sure how best to do that dynamically.
Mar 15 '13 #3
reply
Sign in to post your reply or Sign up for a free account.
Similar topics
3 2502 repost: Access 2003 runtime by: Colin Chudyk |last post by: Hi, Here is my situation. Can anyone provide insight? I have developed a database in Access 2002. I am planning to distribute it as a split MDE (front) / MDB (back) to be used by the Access runtime and also full-version. Some of the client workstations will have Access 2002 installed. Most of them will have the runtime installed. However, I can't find the Office 2002 Developer Edition anywhere! Nobody has Microsoft Access / VBA |
1 6364 Access 97 runtime by: B&C |last post by: Hello, I'm searching a runtime to read access databases on computers which doesn't have access installed. I found this runtime for access 2000, but I would prefer to use the access 97 "reader". Do you know where to download it ? Thanks and sorry for this bad english. Microsoft Access / VBA |
9 39740 Create an enum at runtime by: Lawrence Oluyede |last post by: I have a list of strings and i'd like to build up an enum from them... is there a way to do that? Thanks in advance. -- Lawrence "Rhymes" Oluyede http://loluyede.blogspot.com C# / C Sharp |
5 5485 menustrip stays the sam colour by: Alvo von Cossel I |last post by: hi, i have a modern looking application without the cotrolbox-bar because i've created my own. i have a restore down button with an image that has a grey background. if the user has a different XP style then the button will look weird. how can i make the menustrip not change colour when the user of the PC changes their XP style? -- Alvo von Cossel I of Germany C# / C Sharp |
4 1403 Runtime Controls Addition. by: Leon |last post by: I am building an application that used the placement of panel controls at runtime. Inside of these panels I would like to add multiple buttons. This is part of a scheduling application that I will not be reusing (if I can help it). I get an error on the addition of the button controls.... "Must be placed inside a container with runat="server" attribute"; I can not set the runat="server" for a control that is created at runtime (Panel).... ASP.NET |
10 6115 Is there a stand alone installer for Access 2003 Runtime? by: Lauren Wilson |last post by: I have a desperate short term need for a way to install Access 2003 runtime on client computers. I have the proper license to do so but I cannot seem to find the files to do it like we did with the old Access 2000 Runtime. Also, I cannot use the MS Package & Deployment wizard because it won't allow us to install our app into the specific path that it must be in. It only seems to allow preset macros to define the target install path --... Microsoft Access / VBA |
2387 Merge a MenuStrip into a MenuStrip but not a ContextMenuStrip into a MenuStrip by: academic |last post by: Using ToolStripManager.Merge(ToolStrip,ToolStrip) I've been able to merge a MenuStrip into a MenuStrip but never a ContextMenuStrip into a MenuStrip. From the docs it seems to me I should be able to. Visual Basic .NET |
1 1087 datagrid custom (dynamic) pager build at runtime? by: =?Utf-8?B?cGF0cmlja2RyZA==?= |last post by: Hi guys! I have built a custom pager for my datagrids like in the picture: http://i173.photobucket.com/albums/w65/patrickdrd/dev/grid.jpg I would like to move that inside the datagrid (on the footer), but I'm having trouble with the event, ASP.NET |
1 1881 how do I addhandler to menustrip item by: ngrTerry |last post by: I have a menustrip on my form which I add two options on it at runtime Dim t As ToolStripItem t.Text = "Option1" Me.mnuOrigins.DropDownItems.Add(t) t.Text = "Option2" Me.mnuOrigins.DropDownItems.Add(t) .NET Framework |
12 6426 Setting control to dock fill when you have a menustrip by: Rotsey |last post by: Hi, I have not had a good answer to this question. I put a menustrip on a form and so it is a main menu in affect. Now I put a webbrowser control on the form and set it dock fill. Of course what happens is the menu covers the top of the webbrowser control which i do not want. C# / C Sharp |
9622
What is ONU? 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, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of... General |
9454 Changing the language in Windows 10 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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,... Windows Server |
10109
Maximizing Business Potential: The Nexus of Website Design and Digital Marketing 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 captivates audiences and drives business growth. The Art of Business Website Design Your website is... Online Marketing |
1 10051 The easy way to turn off automatic updates for Windows 10/11 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 most users, this new feature is actually very convenient. If you want to control the update process,... Windows Server |
9916
Discussion: How does Zigbee compare with other wireless protocols in smart home applications? 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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some... General |
8940
AI Job Threat for Devs by: agi2029 |last post by: Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development projectplanning, coding, testing, and deploymentwithout human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea... Career Advice |
1 4018 transfer the data from one system to another through ip address 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 C# / C Sharp |
2 3611
How to add payments to a PHP MySQL app. by: muto222 |last post by: How can i add a mobile payment intergratation into php mysql website. PHP |
3 2854
Comprehensive Guide to Website Development in Toronto: Expert Insights from BSMN Consultancy by: bsmnconsultancy |last post by: In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive... General |
By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.
To disable or enable advertisem*nts and analytics tracking please visit the page.