0

I am using MaskedTextBox in my code to for a date field.

When I am giving maskedTextBox1.Mask = "00/00/0000 00:00 AA" in code,on running the application in my machine it works fine and mask in the textbox appears as [_ _/_ _ _/____ __:__ _ _ _]

But when i am running the same application in another machine, the mask appears as [_ _ _-_ _ _-____ __:__ _ _ _]

How is the / replaced by -? Is the mask machine dependent, if yes how can we avoid this problem?

John Saunders
  • 160,644
  • 26
  • 247
  • 397
user1805377
  • 73
  • 1
  • 9
  • >Another machine means, another system at client location. I debug through the code also, the value assigned to the mask is correct but still it shows '-' instead of '/' on UI. – user1805377 Dec 28 '12 at 04:27
  • I believe it's just user preferences on the target machine. However, I don't know if there is an easy way to force the mask display. – Inisheer Dec 28 '12 at 04:28

2 Answers2

0

I think it has more to do with application culture http://msdn.microsoft.com/en-us/library/system.windows.forms.maskedtextbox.mask.aspx

Sandip Bantawa
  • 2,822
  • 4
  • 31
  • 47
0

This problem can be avoided by providing escape character before '/'.
e.x. maskedTextBox1.Mask = @"00\/00\/0000 00:00 AA";
This will force the system to show '/' on the screen.

John Saunders
  • 160,644
  • 26
  • 247
  • 397
user1805377
  • 73
  • 1
  • 9