473,408 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,408 software developers and data experts.

Iterating through menuitems

Hi all,

I must globalize my application and therefore i must fill the text of
all controls of each form programatically.

When controls, I perform:

foreach (Control c in this.Controls)
{
// rm is my resource manager and culture is the current culture
c.Text = rm.GetString("ClientesForm" + "_" + c.Name, culture);
}

What's my surprise when I discover that MainMenu is not a Control;
it's a Menu object!

So I try to do the same with "Menu m in this.Menu". Then VS.NET tells
me that menuitems can't be iterated with foreach.

What's the way to iterate through menuitems in order to get the text
filled?

Thanks very much.
Nov 16 '05 #1
2 1898
MIGUEL?N. wrote:
Hi all,

I must globalize my application and therefore i must fill the text of
all controls of each form programatically.

When controls, I perform:

foreach (Control c in this.Controls)
{
// rm is my resource manager and culture is the current culture
c.Text = rm.GetString("ClientesForm" + "_" + c.Name, culture);
}
1. Be aware that "GetString" might return "null" !!!

We use the following wrapper function:

public static string BetterGetString(string text, ResourceManager rm,
CultureInfo culture)
{
if (text == null)
return string.Empty;
string res = rm.GetString(text, culture);
if (res == null)
return "<" + text + ">"; // indicate that this text was not translated
return res;
}
So I try to do the same with "Menu m in this.Menu". Then VS.NET tells
me that menuitems can't be iterated with foreach.

foreach (MenuItem m in this.Menu.MenuItems)
{
//...
}

--
Greetings
Jochen
Nov 16 '05 #2
First of all, thanks and sorry, probably my post was not very well
explained. I knew how to iterate with "foreach" in a Menu.MenuItems
collection. The problem is that I can't access the MenuItem.Name
property as I do it with the previous foreach looping, for general
controls. So I don't know how to load menuitems names programatically.
That's my problem.

Any ideas?
Nov 16 '05 #3

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

Similar topics

0
by: Deutsche Dogge | last post by:
Hi. I'M having a weird problem with addign menuitems to a menu dynamically on the popup event of the menuitem containing the container of the menuitems i wanna add (tools -> external -> {list of...
0
by: Kreisquadratur | last post by:
Below is s snippet of my code, which should add menuitems as a submenu of an item in a contextmenu. But only the first time the contextmenu opens the entrys are set correctly. I just don't know why...
1
by: Steve Tan | last post by:
1. How can I loop through all the items and subitems for Menu of a Windows Form (c#) ? Recursive function? 2. How can I uniquely identify a submenu item ? MenuItems doesn't have a Name...
0
by: Brian | last post by:
Create a simple MDI form and a child form, and try the following simple code to add a new menu item on the Edit menu popup: private void editMenu_Popup(object sender, System.EventArgs e) {...
5
by: Davie | last post by:
I'm developing an application on the smartphone. To reduce the size of the application i'm using panels where appropriate instead of forms. As a result of the design, I need to have different...
5
by: Jorge Cavalheiro | last post by:
Hello I am trying to browse thru all menuitens of contextmenus. The form has 3 contextmenus. mi and mi2 as menuitems, f is a form For Each mi In f.ContextMenu.MenuItems For Each mi2 In...
1
by: Bryan | last post by:
How do I iterate through all the items and all child items in a menu control in asp.net 2.0? Thanks, Bryan
3
by: active | last post by:
I have a mainmenu menuitem that contains a Recently Used Files menuitem If at design time I include a menuitem in the Recently Used Files menuitem collection it will display OK If I...
1
by: cnixuser | last post by:
Hello, I am currently attempting to modify an ASP.NET menu that I found online so that I will be better able to control the look and feel of menus that I create in the future. The current one that I...
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
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...
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...
0
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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.