944,057 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Unsolved
  • Views: 4291
  • C# RSS
Oct 11th, 2009
0

Maskedtextbox C#

Expand Post »
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.
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Jimmalmquist is offline Offline
3 posts
since Oct 2009
Oct 11th, 2009
0
Re: Maskedtextbox C#
Has probably to do with international settings. In some countries the , (a comma) is the decimal sign in others it is . (a point)
Reputation Points: 2035
Solved Threads: 645
Senior Poster
ddanbe is offline Offline
3,740 posts
since Oct 2008
Oct 11th, 2009
0
Re: Maskedtextbox C#
No it's not that. The culture is set to fi-FI
Last edited by Jimmalmquist; Oct 11th, 2009 at 2:30 pm.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Jimmalmquist is offline Offline
3 posts
since Oct 2009
Oct 11th, 2009
0
Re: Maskedtextbox C#
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.
Reputation Points: 2035
Solved Threads: 645
Senior Poster
ddanbe is offline Offline
3,740 posts
since Oct 2008
Oct 13th, 2009
0
Re: Maskedtextbox C#
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.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Jimmalmquist is offline Offline
3 posts
since Oct 2009
Oct 14th, 2009
0
Re: Maskedtextbox C#
Changing a char in a string is very easy!
Look :
c# Syntax (Toggle Plain Text)
  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.
Reputation Points: 2035
Solved Threads: 645
Senior Poster
ddanbe is offline Offline
3,740 posts
since Oct 2008

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: help me to show a table from database to my form
Next Thread in C# Forum Timeline: InfoPath Question





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC