473,396 Members | 1,840 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Regarding context menu

alexis4
113 100+
Hi!

I have a ContextMenuStrip inside a form. This has several items like that:



I also attached the image at the bottom of the post.

For some reason, I want to change all items of the context menu simultaneously. So I wrote this peace of code:

Expand|Select|Wrap|Line Numbers
  1. int a = 0;
  2. foreach (ToolStripItem co in contextMenuStrip1.Items)
  3. {
  4.   co.Text = "Menu" + a.ToString();
  5.   a++;
  6. }
  7.  

But what I get is "engl1" and "engl2" menus changed into "menu1" and "menu2" as expected, but "engl11" and "engl12" stayed as they were and didn't change into "menu3" and "menu4" as I wanted to.

So how can I have access to those subitems too?

Thanks!
Attached Images
File Type: jpg contextMenu.JPG (6.4 KB, 193 views)
Sep 2 '11 #1
2 1416
GaryTexmo
1,501 Expert 1GB
Instead of using the ToolStripItem object, use a ToolStripMenuItem object. This has a property called DropDownItems that provides access to the list of sub items. ToolStripItem is a more generic object than ToolStripMenuItem so it doesn't provide as much information. You can follow the inheritance tree by right-clicking on the type in visual studio and selecting Go To Definition. Keep doing this and you will eventually find ToolStripItem :)

You may also want to consider a recursive method to handle processing this, as you could conceivably have a menu N levels deep. This should be easy enough to do but if you need help, please feel free to ask!
Sep 6 '11 #2
alexis4
113 100+
Thank you GaryTexmo, I will work on that and let you know.
Sep 6 '11 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Mohit Gupta | last post by:
Hi all, Lately I have been working on an application in VB .net CF for Pocket PC device. I have a small question about Context Menu. When I try to close the window after context menu is poped...
5
by: Dean L. Howen | last post by:
Dear friends, Could we determine when context menu should appear?
8
by: Dennis C. Drumm | last post by:
Is there a way to modify the standard context menu shown when someone right clicks in a windows text box and that would work for all open windows applications? The standard context menu for...
5
by: lgbjr | last post by:
Hello All, I have several Pictureboxes (linked to an AccessDB) on a VB.NET form. I would like to use a context menu to allow the user to open the picture in their default picture viewer or...
1
by: goRide | last post by:
Hi, I'm looking of a way (preferred - a ready class or dll) to customize the context menu. many application has more controls inside the context menu (like textbox, sliders, checkbox, panel...
3
by: coltrane | last post by:
Can someone direct me to a reference that describes how to create a context menu for a selected row in a datagrid? I have come across many threads regarding context menus and datagrids but they all...
2
by: MCM | last post by:
I'm working on a plotting control. The plotting control will have a context menu with basic commands for "scaling", "zooming", etc. Is there a way that, from the parent form, I can add more...
4
by: Karl | last post by:
Hi all, I want to write an application that is launched from the context menu in Windows Explorer/Computer. That is to say, when I am browsing around my hard drive and get to any location I...
0
by: philaphan80 | last post by:
I'm hoping someone can offer some guidance regarding a concept I have. I'm trying to perform the following within Windows Explorer: 1. Add an entry to the context menu which should be executed...
1
by: paragpdoke | last post by:
Hello Everyone. I am new to Windows programming / registry settings and I need help regarding setting a context menu. Allow me to provide details. - There is a DLL written in C++ which somehow is...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.