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,
- Add a form or a control.
- In Solution Explorer add a new string item into the application scope of the settings file.
- 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.
精彩评论