开发者

Is it good to use .settings for storing controls' text data?

开发者 https://www.devze.com 2022-12-23 14:43 出处:网络
In my Windows Forms applications I often put the controls\' text data (form title, labels texts, button capti开发者_开发百科ons, etc.) into a .settings (feature automatically generated by Visual Studi

In my Windows Forms applications I often put the controls' text data (form title, labels texts, button capti开发者_开发百科ons, 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.


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.


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

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号