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.

Has probably to do with international settings. In some countries the , (a comma) is the decimal sign in others it is . (a point)

No it's not that. The culture is set to fi-FI

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.

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.

Changing a char in a string is very easy!
Look :

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string InputStr = "12,34,5678";
            string DateStr = InputStr.Replace(',', '.');
        }
    }
}

DateStr now contains : "12.34.5467"
But again: you should consider the DateTimePicker control, to input a date in your application.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.