Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. MaskedTextBox mask problem

MaskedTextBox mask problem

Scheduled Pinned Locked Moved C#
questionhelp
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    EnkelIk
    wrote on last edited by
    #1

    Hi All! I have a problem that I can't find the solution of: In an application I'm using MaskedTextBox controls for dates (displaying current value and letting user change value). Default language for application is Swedish and mask is 0000-00-00 (for yyyy-MM-dd). This works fine. The application is also to be run in Finnish and then I set the mask to 00.00.0000 (for dd.MM.yyyy), this does not work at all! The mask is correct but for a reason beyond my comprehension in the text-property of the control the "." (dot) is replaced with "," (comma). I have tried to replace the comma, to overwrite the text property and a number of other things but without success. Is the problem that the control interpretes the date as a number and replaces the dot with the NumberGroupSeparator and NumberDecimalSeparator of the MaskedTextBox.Culture? If so how do I get the control so interprete the date as a date? What can I do to make the MaskedTextBox to work with my Finnish dates??? Thanks! Chris

    D A 2 Replies Last reply
    0
    • E EnkelIk

      Hi All! I have a problem that I can't find the solution of: In an application I'm using MaskedTextBox controls for dates (displaying current value and letting user change value). Default language for application is Swedish and mask is 0000-00-00 (for yyyy-MM-dd). This works fine. The application is also to be run in Finnish and then I set the mask to 00.00.0000 (for dd.MM.yyyy), this does not work at all! The mask is correct but for a reason beyond my comprehension in the text-property of the control the "." (dot) is replaced with "," (comma). I have tried to replace the comma, to overwrite the text property and a number of other things but without success. Is the problem that the control interpretes the date as a number and replaces the dot with the NumberGroupSeparator and NumberDecimalSeparator of the MaskedTextBox.Culture? If so how do I get the control so interprete the date as a date? What can I do to make the MaskedTextBox to work with my Finnish dates??? Thanks! Chris

      D Offline
      D Offline
      dan sh
      wrote on last edited by
      #2

      I guess yes. It is picking things up from the current culture. I think you will need to override that through FormatProvider.

      It's not necessary to be so stupid, either, but people manage it. - Christian Graus, 2009 AD

      1 Reply Last reply
      0
      • E EnkelIk

        Hi All! I have a problem that I can't find the solution of: In an application I'm using MaskedTextBox controls for dates (displaying current value and letting user change value). Default language for application is Swedish and mask is 0000-00-00 (for yyyy-MM-dd). This works fine. The application is also to be run in Finnish and then I set the mask to 00.00.0000 (for dd.MM.yyyy), this does not work at all! The mask is correct but for a reason beyond my comprehension in the text-property of the control the "." (dot) is replaced with "," (comma). I have tried to replace the comma, to overwrite the text property and a number of other things but without success. Is the problem that the control interpretes the date as a number and replaces the dot with the NumberGroupSeparator and NumberDecimalSeparator of the MaskedTextBox.Culture? If so how do I get the control so interprete the date as a date? What can I do to make the MaskedTextBox to work with my Finnish dates??? Thanks! Chris

        A Offline
        A Offline
        Alan N
        wrote on last edited by
        #3

        Hi, Have you read the MSDN notes for the Mask property? To me they suggest that the date separator / will be interpreted according FormatProvider. Alan.

        E 1 Reply Last reply
        0
        • A Alan N

          Hi, Have you read the MSDN notes for the Mask property? To me they suggest that the date separator / will be interpreted according FormatProvider. Alan.

          E Offline
          E Offline
          EnkelIk
          wrote on last edited by
          #4

          Thank you Alan! You've made the day for our whole project team! :-) /Chris

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups