2
votes

Relatively new to WinForms but I'm working on a small business app. Anyway, where should I be storing strings and other resources for the form? I will have labels like Name, Address, etc. Should I just hard-code them in the designer? Or store them in a .resx file? If so, which .resx file (Form or Properties)?

I'm just trying to figure out what a "seasoned" C#/.NET developer deems good practice? My first choice would be the Form's .resx file.

2
Are you planning to support multiple languages or change the content dynamically without re-compiling the application?Servy
No I will not need to do any of that.keelerjr12
The 'trick' is to predict where your application is going, what it will need to do down the road, and to design for those changes. You want your software to be complex enough to handle what's coming, but no more complex than it needs to be. Don't stress over these decisions too much however, give them some thought and make a decision. inevitably, you will get some things right and some things wrong. Good luck.Matthew Vines

2 Answers

8
votes

Typically fields like Name and Address will not be changed unless it will be a multilingual application. If it is an English only application and the labels are unlikely to change, I would leave it hard coded.

1
votes

To follow up on the other answers: if you are going to localise this application (or at least anticipate localising this application) then typically you'd use the built-in Resources features in .NET (Project > Add New Item > Resources) you can get WinForms controls to load properties such as .Text from resources automatically without having to manually define it.