473,765 Members | 2,081 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How To: Work around a Users Region Setting (Date issue)???

My PC's Region setting is set to "English (Canada)"... cause I am in Canada
(eh?) (: I'm using VB.net, standard edition (v1?)

So I wrote my application based on this Region. I've both Short and Long
dates being displayed (including a DateTimePicker) .

BUT... at work, there are some machines which the Region is the ol' default of
"English (United States)".

Canadian:
Short = dd/MM/yy
Long = MMMM d, yyyy

USA:
Short = M/d/yyy
Long = dddd, MMMM dd, yyyy

What my issue is is that my Date displays (both for long and short) are either
OK or Screwed up depending upon the Region display. This because my labels,
textboxes, etc. have 'fixed' widths.

Bah! Changing the PC's Regions is NOT an option (I won't go into that).

So how can I have my app display what I want?

I know I can 'build' the date string. Such for a Label, I can have:
myMonth & myDay & myYear... etc.

But the DateTimePicker is got me stumped.

Prefferably, there must be an easier way to do this so that 'globally' my app
works for English (Canadian) and not screw up the Users PC Region setting.

Thanks

James
Jul 21 '05 #1
8 2558
Why don't you use Formatting?

1. String.Format(" mmDDyyyy",myDat e)
2. myDate.ToString ("mmDDyyyy")

Remember that month should be DD and not dd. I have done that once before
and was writing minutes instead of months!! Bad eh? This is case sensitive.
Mind you I believe it is a by-design bug. ;-)
"JamesBV" <No****@telus.n et> wrote in message
news:ov******** *************** *********@4ax.c om...
My PC's Region setting is set to "English (Canada)"... cause I am in Canada (eh?) (: I'm using VB.net, standard edition (v1?)

So I wrote my application based on this Region. I've both Short and Long
dates being displayed (including a DateTimePicker) .

BUT... at work, there are some machines which the Region is the ol' default of "English (United States)".

Canadian:
Short = dd/MM/yy
Long = MMMM d, yyyy

USA:
Short = M/d/yyy
Long = dddd, MMMM dd, yyyy

What my issue is is that my Date displays (both for long and short) are either OK or Screwed up depending upon the Region display. This because my labels, textboxes, etc. have 'fixed' widths.

Bah! Changing the PC's Regions is NOT an option (I won't go into that).

So how can I have my app display what I want?

I know I can 'build' the date string. Such for a Label, I can have:
myMonth & myDay & myYear... etc.

But the DateTimePicker is got me stumped.

Prefferably, there must be an easier way to do this so that 'globally' my app works for English (Canadian) and not screw up the Users PC Region setting.

Thanks

James

Jul 21 '05 #2
You can manually set the current thread's UI Culture to whatever you want.
System.Threadin g.CurrentUICult ure (something around there).
-mike
MVP

"JamesBV" <No****@telus.n et> wrote in message
news:ov******** *************** *********@4ax.c om...
My PC's Region setting is set to "English (Canada)"... cause I am in Canada (eh?) (: I'm using VB.net, standard edition (v1?)

So I wrote my application based on this Region. I've both Short and Long
dates being displayed (including a DateTimePicker) .

BUT... at work, there are some machines which the Region is the ol' default of "English (United States)".

Canadian:
Short = dd/MM/yy
Long = MMMM d, yyyy

USA:
Short = M/d/yyy
Long = dddd, MMMM dd, yyyy

What my issue is is that my Date displays (both for long and short) are either OK or Screwed up depending upon the Region display. This because my labels, textboxes, etc. have 'fixed' widths.

Bah! Changing the PC's Regions is NOT an option (I won't go into that).

So how can I have my app display what I want?

I know I can 'build' the date string. Such for a Label, I can have:
myMonth & myDay & myYear... etc.

But the DateTimePicker is got me stumped.

Prefferably, there must be an easier way to do this so that 'globally' my app works for English (Canadian) and not screw up the Users PC Region setting.

Thanks

James

Jul 21 '05 #3
Why don't you use Formatting?

1. String.Format(" mmDDyyyy",myDat e)
2. myDate.ToString ("mmDDyyyy")


Hmmmm... okay. But will this allow me to change the DateTimePicker display?
I'm not sure if it will.

I changed my Region Date to USA standard.

I then tried putting MMMM d, yyyy in the Properties "Custom Format" line...
and then changed the "Format" line to 'Custom'. But the display still showed
USA format.

Other than that... the other stuff (labels, textboxes) work fine.

Idea?

Thanks.

James
Jul 21 '05 #4
James,

DateTimePicker is one of those dodgy controls (e.g you cannnot set
background colour for the text) and I am not surprised if it behaves badly.
But, I tested that on my machine (UK setting) with "MMMM d, yyyy" in format
property and setting the format to custom and it did show "November 12,
2003". Are you trying to use "Value" property in code? I am using VB.NET
2003 and that might cause the difference (very unlikely though)

Michael's approach is very professional and polished (he is MVP after all
;-)):
System.Threadin g.Thread.Curren tThread.Current UICulture = New
System.Globaliz ation.CultureIn fo("en-CA")

You might as well use that.

Cheers
Ali


"JamesBV" <No****@telus.n et> wrote in message
news:0u******** *************** *********@4ax.c om...
Why don't you use Formatting?

1. String.Format(" mmDDyyyy",myDat e)
2. myDate.ToString ("mmDDyyyy")
Hmmmm... okay. But will this allow me to change the DateTimePicker

display? I'm not sure if it will.

I changed my Region Date to USA standard.

I then tried putting MMMM d, yyyy in the Properties "Custom Format" line... and then changed the "Format" line to 'Custom'. But the display still showed USA format.

Other than that... the other stuff (labels, textboxes) work fine.

Idea?

Thanks.

James

Jul 21 '05 #5
background colour for the text) and I am not surprised if it behaves badly.
But, I tested that on my machine (UK setting) with "MMMM d, yyyy" in format
I don't know what I did.. but just before finding this 2nd reply of yours. I
got it to work!! Must have done something wrong the first time. (sigh)
Michael's approach is very professional and polished (he is MVP after all
;-)):
System.Threadi ng.Thread.Curre ntThread.Curren tUICulture = New
System.Globali zation.CultureI nfo("en-CA")


True. Where does this go? In Form Load? I placed it there but nothing
happened. Obviously this needs more work.

Thanks!

James
Jul 21 '05 #6
You can manually set the current thread's UI Culture to whatever you want.
System.Threadi ng.CurrentUICul ture (something around there).


Alireza gave me the following:

System.Threadin g.Thread.Curren tThread.Current UICulture = New
System.Globaliz ation.CultureIn fo("en-CA")

Just got to place it, use it properly (of which I have no idea... never have
had the 'pleasure' of Threading before) (:

Thanks!

James
Jul 21 '05 #7
If you want your whole app to be in a certain culture, you can set the
thread's culture on startup of your app and leave it.

If it's only for a particular piece of code, then you should save the
original culture, set the new one, then revert when you are done using it.

The *real way* is to figure out how to make your app respond correctly no
matter what culture it's running on. Manual override is a hackish solution.
But if it's just for an internal system that doesn't have international
requirments, it *probably* won't matter (unless some VP from Korea comes
over and runs it and it crashes ;)).

-mike
MVP

"JamesBV" <No****@telus.n et> wrote in message
news:je******** *************** *********@4ax.c om...
You can manually set the current thread's UI Culture to whatever you want.System.Threadi ng.CurrentUICul ture (something around there).
Alireza gave me the following:

System.Threadin g.Thread.Curren tThread.Current UICulture = New
System.Globaliz ation.CultureIn fo("en-CA")

Just got to place it, use it properly (of which I have no idea... never

have had the 'pleasure' of Threading before) (:

Thanks!

James

Jul 21 '05 #8
If you want your whole app to be in a certain culture, you can set the
thread's culture on startup of your app and leave it.
Actually it is only for work here in Canada. I just wanted to overcome the
PC's which have the USA date/time Region setting because I did my code based
on my PC (being Canadian Region setting).
requirments, it *probably* won't matter (unless some VP from Korea comes
over and runs it and it crashes ;)).


LOL...

What I ended up doing (because it only affected 5 lines) was to 'force' the
Code Format. Tried it with both Regions set for my PC and I think I've got it
licked.

But it would have been nicer (of course) to have set it in one spot. Maybe in
the future when I go International (:

Thanks again for your Time!

James
Jul 21 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2693
by: BBFrost | last post by:
We have a data entry application written within Framework 1.0 that contains 20+ custom user controls. The controls overlay each other so that only one custom control is visible at a time. What is the best way to keep the cursor from jumping to another non-visible control when the user tabs past the (currently designated) last control on the form. I've had some luck using the Leave event but the last visible control can change...
5
5291
by: fbwhite | last post by:
I know this issue has been brought up many times, but I have tried many of the solutions to no avail. I wanted to give my specific case to see if someone could be of any help. We are using the sessionstate inproc mode and users are randomly losing their session. I do not believe it is happening across all users at one time. It seems to happen to different users at different times, but I am only going off heresay. The aspnet worker...
8
1220
by: JamesBV | last post by:
My PC's Region setting is set to "English (Canada)"... cause I am in Canada (eh?) (: I'm using VB.net, standard edition (v1?) So I wrote my application based on this Region. I've both Short and Long dates being displayed (including a DateTimePicker). BUT... at work, there are some machines which the Region is the ol' default of "English (United States)". Canadian:
6
4900
by: scottyman | last post by:
I can't make this script work properly. I've gone as far as I can with it and the rest is out of my ability. I can do some html editing but I'm lost in the Java world. The script at the bottom of the html page controls the form fields that are required. It doesn't function like it's supposed to and I can leave all the fields blank and it still submits the form. Also I can't get it to transfer the file in the upload section. The file name...
5
10604
by: Oleg Subachev | last post by:
Are there good classes to work with .INI-files from C# ? Oleg Subachev
0
1318
by: Steve | last post by:
To begin, I'm using Adobe's Spry Framework for all my data in my XML page, it saves space and code on the HTML. Well, I want to make it so that certain cells are chosen and are either highlighted with green or red depending on a condition. ====================================XML====================================== <?xml version="1.0" encoding="iso-8859-1"?> <?xml-stylesheet type="text/xsl" href="bowlgames.xsl"?> <bowlgames>
9
1997
by: =?Utf-8?B?Sm9obiBCYWlsZXk=?= | last post by:
I have a ASP .Net page that allows moving around items on the page through javascript. This page works fine in IE. In FireFox however, I have found that if the page is using XHTML 1.0 Transitional as the doctype, you cannot set the style.left and style.top properties of image or div tags. If you remove the doctype from the page it works just fine, although I would rather not do this. You can work around this by setting the cssText...
6
2237
by: Kelii | last post by:
Hello, So I have a form which shows all items available for sale, when it was last sold, where it was last sold, and whether it is active or inactive. I would like to be able to edit the active/inactive field (its a yes/ no or boolean type field); however, I am not able to make these edits because of the max aggregate function used on the sale date.
3
689
by: =?Utf-8?B?Um9nZXIgTWFydGlu?= | last post by:
Note: My apologies for repeating this post from last week, but my nospam alias and profile account were incorrect. I think I have fixed this, so hopefully this post will trigger MS into a response per their MSDN policy. -------------------- I have a web site under .NET 2.0 that renders videos using the Silverlight media player. The web page looks like this: <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="video2.aspx.cs"
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9398
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10156
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10007
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7375
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5275
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2805
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.