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. Validating a date in a DateTimePicker

Validating a date in a DateTimePicker

Scheduled Pinned Locked Moved C#
help
5 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.
  • D Offline
    D Offline
    drey1
    wrote on last edited by
    #1

    this is what i need to do: user enters a date in the DateTimePicker. the code needs to validate the date agains a few criterias. if it does not pass the validation. display a message asking if the user really wants that date. if the user wants to continue with the date, just go ahead. if not the date should go back to what it was. I am having the hardest time to get the program to flow thist way. I tried to extend the datetimepicker to add a onchanging event, i tried the validating event. But so far there is always one thing in this flow that does not work. Can any one help! thank you tephra:confused:

    D H D 3 Replies Last reply
    0
    • D drey1

      this is what i need to do: user enters a date in the DateTimePicker. the code needs to validate the date agains a few criterias. if it does not pass the validation. display a message asking if the user really wants that date. if the user wants to continue with the date, just go ahead. if not the date should go back to what it was. I am having the hardest time to get the program to flow thist way. I tried to extend the datetimepicker to add a onchanging event, i tried the validating event. But so far there is always one thing in this flow that does not work. Can any one help! thank you tephra:confused:

      D Offline
      D Offline
      Darryl Borden
      wrote on last edited by
      #2

      Use the TextChanged event Darryl Borden Principal IT Analyst dborden@eprod.com

      1 Reply Last reply
      0
      • D drey1

        this is what i need to do: user enters a date in the DateTimePicker. the code needs to validate the date agains a few criterias. if it does not pass the validation. display a message asking if the user really wants that date. if the user wants to continue with the date, just go ahead. if not the date should go back to what it was. I am having the hardest time to get the program to flow thist way. I tried to extend the datetimepicker to add a onchanging event, i tried the validating event. But so far there is always one thing in this flow that does not work. Can any one help! thank you tephra:confused:

        H Offline
        H Offline
        hooray
        wrote on last edited by
        #3

        simply use the validating event with this event you can cancel the leave event via eventarg

        1 Reply Last reply
        0
        • D drey1

          this is what i need to do: user enters a date in the DateTimePicker. the code needs to validate the date agains a few criterias. if it does not pass the validation. display a message asking if the user really wants that date. if the user wants to continue with the date, just go ahead. if not the date should go back to what it was. I am having the hardest time to get the program to flow thist way. I tried to extend the datetimepicker to add a onchanging event, i tried the validating event. But so far there is always one thing in this flow that does not work. Can any one help! thank you tephra:confused:

          D Offline
          D Offline
          drey1
          wrote on last edited by
          #4

          The problem with the validating event is the messagebox. the messagebox kicks the "valuechanged" event. even if i disable the event before the messagebox, the value already changed and the event is not kicked afterwards when i want to. also there is the path that does not go through the messagebox(when the date is valid). and so on... I keep getting caught on something. it would be simpler if i could get the messagebox to stop changing the value of the datetimepicker before the validating is finished. thank you

          D 1 Reply Last reply
          0
          • D drey1

            The problem with the validating event is the messagebox. the messagebox kicks the "valuechanged" event. even if i disable the event before the messagebox, the value already changed and the event is not kicked afterwards when i want to. also there is the path that does not go through the messagebox(when the date is valid). and so on... I keep getting caught on something. it would be simpler if i could get the messagebox to stop changing the value of the datetimepicker before the validating is finished. thank you

            D Offline
            D Offline
            drey1
            wrote on last edited by
            #5

            ...another problem is that the validationEvent is not trigged when I choose a date in the calendar.

            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