C#: How to bind the text of a winforms button to a resource

后端 未结 6 1786
刺人心
刺人心 2021-01-02 21:32

We have a resource file with lots of translated strings used various places in our application. Is there a better way for binding for example the text of a button to a certa

6条回答
  •  旧巷少年郎
    2021-01-02 22:25

    You can do:

    using System.Resources;
    using System.Reflection;
    
    Assembly assembly = this.GetType().Assembly;
    resman = new ResourceManager("StringResources.Strings", assembly);
    btnButton.Text = resman.GetString("ButtonName");
    

提交回复
热议问题