将 MenuStrip 项目文本移动到资源文件中

发布于 2024-12-28 07:21:13 字数 91 浏览 2 评论 0原文

我正在使用 .NET WinForms (C#) 我有一个带有菜单条控件的表单,我在设计器中添加了菜单项并为其分配了测试,现在我想将此文本移动到资源文件中。我该怎么做?

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 ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

好久不见√ 2025-01-04 07:21:13

您可以使用 Resourcemanager 设置 MenuItem 的字符串。

所以你可以有类似的东西:

MenuItem topLevel = mainMenu.MenuItems.Add("&XXX");
MenuItem first = new MenuItem();
first.Text = [Text from ResourceManager]
topLevel.MenuItems.Add(new MenuItem("&New"));

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"));
哭泣的笑容 2025-01-04 07:21:13
  1. 项目>>添加新项目>资源文件
  2. 在资源中添加字符串...
  3. 打开 FormDesigner.cs,找到 Text 并将其替换为
    this.stripItem.Text = 全局::your_app_namespace.resource_name.resource_value;
  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;
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文