Introduction In this article I try to show like freeing the application from Windows form of the regional configuration of Windows. The two culture values of a Visual basic or Visual C# application determine what resources are loaded for an application and how information like currency, numbers and dates is formatted. The resources loaded are determined by the UI culture setting, and the formating options are determined by the culture setting.
The first place an application will search for culture valuesis the CurrentCulture and CurrentUICulture properties. You can set these values in code as shown in the following procedure.The CurrentCulture property's default value is the operating system's User Locale, which is set in the Regional Options control panel.
The CurrentUICulture property's default value is the operating system's user interface (UI) language, which is the language of your
operating system UI. On Windows 2000 and Windows XP MultiLanguage Edition, the CurrentUICulture defaults to the current user UI language settings.
If you want to override the settings of the user or operating system, set the CurrentCulture and CurrentUICulture properties. Usually, you want to specify a culture so that every part of the application's UI is appropriate to that culture. So you must set the culture before the InitializeComponent method is called.
Code of Program.cs
//Program.cs using System; using System.Collections.Generic; using System.Configuration; using System.Windows.Forms; //agregar este espacio de nombreusing System.Threading;//agregar este espacio de nombre namespace MiApp { static class Program { [STAThread] public static void "on" />Main()"on" /> { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); // Seteamos la cultura a Espa�ol Argentina Thread.CurrentThread.CurrentCulture = new CultureInfo("es-AR"); Thread.CurrentThread.CurrentUICulture = new CultureInfo("es-AR");// Application.Run(new form1()); } } }
本文介绍如何通过设置应用程序的文化属性来实现跨文化配置,确保应用程序能够正确加载资源并按指定文化格式化货币、数字和日期等信息。具体介绍了如何在代码中设置 CurrentCulture 和 CurrentUICulture 属性。
477

被折叠的 条评论
为什么被折叠?



