亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何為整個 winform 應用程序設置文化

如何為整個 winform 應用程序設置文化

C#
慕村9548890 2021-11-07 19:20:30
我想為整個 winform 應用程序設置文化。我怎樣才能做到這一點?我Program.cs像這樣改變了我的文件:using System;using System.Collections.Generic;using System.Globalization;using System.Linq;using System.Threading.Tasks;using System.Windows.Forms;namespace Divar{    static class Program    {        /// <summary>        /// The main entry point for the application.        /// </summary>        [STAThread]        static void Main()        {            var culture = new CultureInfo("en-US");            CultureInfo.DefaultThreadCurrentCulture = culture;            CultureInfo.DefaultThreadCurrentUICulture = culture;            Application.EnableVisualStyles();            Application.SetCompatibleTextRenderingDefault(false);            Application.Run(new RadForm1());        }    }}我做對了嗎?還有另一個鏈接:(請看一看)https://www.c-sharpcorner.com/forums/set-cultureinfo-for-winform-application這取得了有限的成功,因此在 InitializeComponent() 之前的“Form1”頂部,我放置了:    System.Globalization.CultureInfo cultureInfo = new System.Globalization.CultureInfo("en-GB");    Application.CurrentCulture = cultureInfo;    System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.GetCultureInfo("en-GB");是否有必要在每種形式的 InitializeComponent() 之前添加這三行?
查看完整描述

1 回答

?
MM們

TA貢獻1886條經驗 獲得超2個贊

將這兩個設置Main為所需的文化: CultureInfo.DefaultThreadCurrentCulture CultureInfo.DefaultThreadCurrentUICulture


此外,您可以隨時更改Application.CurrentCulture應用程序當前線程上的文化。


[STAThread]

static void Main()

{

    var culture = CultureInfo.GetCultureInfo("en-US");


    // this may fail sometimes: (see Drachenkatze's comment below)

    // var culture = new CultureInfo("en-US");


    //Culture for any thread

    CultureInfo.DefaultThreadCurrentCulture = culture;


    //Culture for UI in any thread

    CultureInfo.DefaultThreadCurrentUICulture = culture;


    //Culture for current thread (STA)

    //no need for: Application.CurrentCulture = culture;


    //Thread.CurrentThread.CurrentCulture == Application.CurrentCulture

    //no need for: Thread.CurrentThread.CurrentCulture = culture;


    Application.EnableVisualStyles();

    Application.SetCompatibleTextRenderingDefault(false);

    Application.Run(new RadForm1());

}


查看完整回答
反對 回復 2021-11-07
  • 1 回答
  • 0 關注
  • 255 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號