使用.settings来存储控件好不好?文本数据?

发布于 2024-08-24 21:31:12 字数 670 浏览 1 评论 0原文

在我的 Windows 窗体 应用程序中,我经常放置控件的文本数据(表单标题、标签文本、按钮标题等)到 .settings(由 Visual Studio 自动生成的功能 - 基于 ApplicationSettingsBase 类)。特别是,

  1. 添加表单或控件。
  2. 在解决方案资源管理器中,将新的字符串项添加到设置文件的应用程序范围中。
  3. 将控件文本属性与设置文件的相应项绑定(通过属性绑定)。

这样做的好处是我的所有文本数据都收集在一个地方,并且易于检查和编辑。当我想对多个控件使用相同的文本时,它也很方便。

但是,我还没有听说有人以这种方式使用 .settings 。例如,在创建多语言应用程序的教程中,建议直接在控件属性中输入文本。

那么,使用 .settings 存储控件文本数据是一个好习惯吗?

答案的简要结论:
在 .settings 中存储控件文本数据常见做法。

In my Windows Forms applications I often put the controls' text data (form title, labels texts, button captions, etc.) into a .settings (feature automatically generated by Visual Studio - based on the ApplicationSettingsBase class). In particular,

  1. Add a form or a control.
  2. In Solution Explorer add a new string item into the application scope of the settings file.
  3. Bind the control text property with the corresponding item of the settings file (through the property binding).

The good point of this is that all my text data is collected in one place and is easy to check and edit. Also it is convenient when I want to use the same text for several controls.

However, I haven't heard that somebody uses the .settings such way. In tutorials for creating multilingual applications, for example, it is recommended to enter texts directly into the control property.

So, is it good practice to use .settings for storing controls text data?

Brief conclusion from the answers:
Storing controls text data in the .settings is not common practice.

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

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

发布评论

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

评论(2

思慕 2024-08-31 21:31:12

使用设置来记住用户的信息,例如窗口大小、位置、状态(最小化、最大化、正常)、组合框的当前选定项、复选框的选中状态等。可以为用户绑定并在下次自动重置的内容他/她运行程序的时间。

按钮文本属于资源文件,以便在需要时简化本地化。

Use the settings to remember things for the user, like window size, location, state (minimized, maximized, normal), currently selectedItem of comboboxes, checked state of checkboxes, etc. Things that can be bound and automatically reset for the user the next time he/she runs the program.

Button text belong in resource files to simplify localization if needed.

南街女流氓 2024-08-31 21:31:12

此类数据属于应用程序的资源文件。这样它们就可以本地化。

This kind of data belongs in the application's resource file(s). That way they can be localized.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文