Friday, August 13, 2004

Cultural Settings.

You can use "Application.CurrentCulture" to set these settings.

To keep it simple you can do it like :

Application.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(new
System.Configuration.AppSettingsReader().GetValue("ur-PK",typeof(string)).ToString() );


Or if you want to parameterize it then you may use the following:

In the following snippet I have defined my culture settings in a config file. The tag goes like this :

add key="ApplicationCulture" value="ur-PK"


private void setCurrentCultureInfo(){

/// set ur culture information here.
Application.CurrentCulture = System.Globalization.CultureInfo.CreateSpecificCulture(new
System.Configuration.AppSettingsReader().GetValue("ApplicationCulture",typeof(string)).ToString() );
Application.CurrentCulture.DateTimeFormat = System.Globalization.DateTimeFormatInfo.CurrentInfo;
}

No comments: