Tuesday, April 14, 2020

[C#][Resolved] c# textbox get text from resource

Firstly you need create an resource in "Resources.resx" file,
such as add Name as "title" and Value as "A Big Big Title" in your Resource.resx

Name      Value              Comment
========================================
title     A Big Big Title    

And than get it by "Properties.Resources.title". An example:

Label labelTitle = new Label();
labelTitle.Name = "labelTitle";
labelTitle.Size = new System.Drawing.Size(130,20);
labelTitle.TabIndex = 1;
labelTitle.Text = Properties.Resources.title;

And then you will found string "A Big Big Title" was shown in your design panel or at the result of your application.

Reference:
https://stackoverflow.com/questions/1508570/read-string-from-resx-file-in-c-sharp

No comments:

Post a Comment