开发者

Facing problem in initialization of components in C#

I am a student C# programmer. I am just learning Localization and Globalization. I am just created a button to change the current culture (CurrentCulture and CurrentUICulture) of the current thread. But after running this program this button is not working as I need. Button click event I written is like below:

开发者_运维技巧
    private void BtnLocalized_Click(object sender, EventArgs e)
    {
        CultureInfo CI = new CultureInfo("hi-IN");
        if (Thread.CurrentThread.CurrentCulture != CI)
        {
            Thread.CurrentThread.CurrentCulture = CI;
            Thread.CurrentThread.CurrentUICulture = CI;
        }
        else
        {
            CI = new CultureInfo("en-IN");
            Thread.CurrentThread.CurrentCulture = CI;
            Thread.CurrentThread.CurrentUICulture = CI;
        }
    }

I also tried calling InitializeComponent() method after else block. But it just create another button component without dispossing the current button.

How can I re-initialized this button

Edit:

I just want to change the Text properties with my current local language set bt this application.


The labels of the form are set when the form is created and are not automatically updated.

There are two options:

  1. The easy option is to close and re-open the form;

  2. The difficult option is to manually update the labels of all controls of your form. If you look in the "Designer.cs" of your form, you can see how the labels are set. You can duplicate such a mechanism yourself.

I would go for option 1.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜