Hi,
I know this may be been asked more than once, but Im still unable to make it work, and its something that im doing wrong for sure.
in Program.Main, after the form show, i have the code below, but the dates are not with the separator i defined.
What am i doing wrong?
”’### Definir o regional settings apenas para a propria aplicaçao ###’
Threading.Thread.CurrentThread.CurrentUICulture = New Globalization.CultureInfo(“pt-PT”)
Threading.Thread.CurrentThread.CurrentCulture = Globalization.CultureInfo.CreateSpecificCulture(“pt-PT”)
‘ UI Culture
Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.DateSeparator = “-” ‘ separador entre datas
Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.ShortDatePattern = “dd-MM-yyyy” ‘ dd-MM-yyyy
Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.LongDatePattern = “dddd, d’ de ‘MMMM’ de ‘yyyy”
Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.LongTimePattern = “HH:mm:ss” ‘ HH:mm:ss
Threading.Thread.CurrentThread.CurrentUICulture.DateTimeFormat.TimeSeparator = “:” ‘ separador nas horas
‘ valores do currency
Threading.Thread.CurrentThread.CurrentUICulture.NumberFormat.CurrencySymbol = “€”
Threading.Thread.CurrentThread.CurrentUICulture.NumberFormat.CurrencyDecimalSeparator = “,”
Threading.Thread.CurrentThread.CurrentUICulture.NumberFormat.CurrencyDecimalDigits = 2
Threading.Thread.CurrentThread.CurrentUICulture.NumberFormat.CurrencyGroupSeparator = “.”
‘ valores numericos
Threading.Thread.CurrentThread.CurrentUICulture.NumberFormat.NumberDecimalSeparator = “,”
Threading.Thread.CurrentThread.CurrentUICulture.NumberFormat.NumberDecimalDigits = 2
Threading.Thread.CurrentThread.CurrentUICulture.NumberFormat.NumberGroupSeparator = “.”
Threading.Thread.CurrentThread.CurrentUICulture.NumberFormat.NegativeSign = “-”
‘ culture
Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.DateSeparator = “-” ‘ separador entre datas
Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern = “dd-MM-yyyy”
Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.LongDatePattern = “dddd, d’ de ‘MMMM’ de ‘yyyy”
Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.LongTimePattern = “HH:mm:ss”
Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat.TimeSeparator = “:” ‘ separador nas horas
‘ valores do currency
Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencySymbol = “€”
Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalSeparator = “,”
Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyDecimalDigits = 2
Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.CurrencyGroupSeparator = “.”
‘ valores numericos
Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalSeparator = “,”
Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberDecimalDigits = 2
Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NumberGroupSeparator = “.”
Threading.Thread.CurrentThread.CurrentCulture.NumberFormat.NegativeSign = “-“
You can’t set the locale for a single control. The culture in .NET can be set for the thread or for each call. Threads are reused for each web request so if you set it for the thread you have to set it each time before the request is handled. This is what Wisej does for you.
Add:
“culture”: “pt”
in Default.json
See
// culture: The default culture of the application. Default: “auto” (detects the culture from the browser.)
And
https://wisej.com/docs/2.0/html/Configuration.htm (culture).
See attached image.
Send a test case showing the problem, I cannot reproduce.
If you edited the .json configuration file you have to restart IIS or IIS Express.
Luca,
Well i-m not getting how to do it, my fault.
for example, how would it be possible to define this globally for, for example in the datagridview, to make it display the format i want?
Its always showing 14/25/2019 14.00.00 PM
And i want the portuguese format that is 25-14-2019 14:00:00
grid.Columns(“last_login”).ValueType = GetType(DateTime)
For what i saw in the examples, i-ll have to specify it every time, is it true?
this.labelNumber.Text = 12345678.ToString(“c”);
this.labelCurrency.Text = 12345678.ToString(“c”);
this.labelDateTime.Text = DateTime.Now.ToString(“F”);
You can’t change the localization of the current thread. Every request is a new thread out of the pool. Web apps don’t have a UI thread.
Use the several options provided by Wisej:
https://wisej.com/docs/2.0/html/Localization.htm
https://wisej.com/docs/2.0/html/Configuration.htm
https://github.com/iceteagroup/wisej-examples (Localization and RuntimeLocalization)
Please login first to submit.