move MenuStrip item text into resource file

553 Views Asked by At

I am using .NET WinForms (C#) I have a form with a menustrip control in it, I added menu items in the designer and assigned test to them, now I want to move this text into a resource file. how do I do that ?

2

There are 2 best solutions below

1
On

You can use Resourcemanager to set the string of the MenuItem.

So you can have something like:

MenuItem topLevel = mainMenu.MenuItems.Add("&XXX");
MenuItem first = new MenuItem();
first.Text = [Text from ResourceManager]
topLevel.MenuItems.Add(new MenuItem("&New"));
0
On
  1. Project > Add New Item > Resourece File
  2. Add string in resource...
  3. Open your FormDesigner.cs, find and replace Text to this.stripItem.Text = global::your_app_namespace.resource_name.resource_value;