Maskedtextbox C#

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Oct 2009
Posts: 3
Reputation: Jimmalmquist is an unknown quantity at this point 
Solved Threads: 0
Jimmalmquist Jimmalmquist is offline Offline
Newbie Poster

Maskedtextbox C#

 
0
  #1
Oct 11th, 2009
i need help with a maskedtextbox in a C# applikation. I want want it to display the date in the following format "00.00.0000" but it refuses to show the "." instead it shows "00,00,0000". I have tried several different solution but none of them works.

The mask is correct but the .Text attribute refuses to show "." but converts them to "," instead

Does anyone has any ideas about this or has anyone come across this before?

I'm looking forward for your help.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,933
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 277
ddanbe's Avatar
ddanbe ddanbe is online now Online
Posting Virtuoso
 
0
  #2
Oct 11th, 2009
Has probably to do with international settings. In some countries the , (a comma) is the decimal sign in others it is . (a point)
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 3
Reputation: Jimmalmquist is an unknown quantity at this point 
Solved Threads: 0
Jimmalmquist Jimmalmquist is offline Offline
Newbie Poster
 
0
  #3
Oct 11th, 2009
No it's not that. The culture is set to fi-FI
Last edited by Jimmalmquist; Oct 11th, 2009 at 2:30 pm.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,933
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 277
ddanbe's Avatar
ddanbe ddanbe is online now Online
Posting Virtuoso
 
0
  #4
Oct 11th, 2009
I set a mask of 00.00.0000 and had absolutely no problem with it.
I even could set a date like 56.67.5678 !
I should advise you to use a DateTimePicker control instead.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Join Date: Oct 2009
Posts: 3
Reputation: Jimmalmquist is an unknown quantity at this point 
Solved Threads: 0
Jimmalmquist Jimmalmquist is offline Offline
Newbie Poster
 
0
  #5
Oct 13th, 2009
You're right the control doesn't know it it's a date or another type of mask. It read the decimalseparator from the culture wich for finnish so need one of two solutions.

1. owerwrite the comma and set it to "." this is not so easy.
2. Get the maskedtextbox to validate the input as a date.
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 1,933
Reputation: ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of ddanbe has much to be proud of 
Solved Threads: 277
ddanbe's Avatar
ddanbe ddanbe is online now Online
Posting Virtuoso
 
0
  #6
Oct 14th, 2009
Changing a char in a string is very easy!
Look :
  1. namespace ConsoleApplication1
  2. {
  3. class Program
  4. {
  5. static void Main(string[] args)
  6. {
  7. string InputStr = "12,34,5678";
  8. string DateStr = InputStr.Replace(',', '.');
  9. }
  10. }
  11. }

DateStr now contains : "12.34.5467"
But again: you should consider the DateTimePicker control, to input a date in your application.
Today is a gift, that's why it is called "The Present".
Make love, no war. Cave ab homine unius libri.
Danny
Reply With Quote Quick reply to this message  
Reply

Tags
format, string

Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC