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. How to set the datetimpicker value back to current datetime on a buttion click

How to set the datetimpicker value back to current datetime on a buttion click

Scheduled Pinned Locked Moved C#
csharptutorialquestion
6 Posts 5 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.
  • A Offline
    A Offline
    Anu Palavila
    wrote on last edited by
    #1

    I am with a C#.net Inventory application in one of my form there is a datetimepicker whose value my change according to some selections how can I set the datetimpicker value back to current datetime on a buttion click. I put like datetimepicker1.Text=DateTime.Now.Date.ToString(); but its text is not getting the current datetime Thanks In advance Regarda Anu Palavila

    Thanks & Regards

    D V 2 Replies Last reply
    0
    • A Anu Palavila

      I am with a C#.net Inventory application in one of my form there is a datetimepicker whose value my change according to some selections how can I set the datetimpicker value back to current datetime on a buttion click. I put like datetimepicker1.Text=DateTime.Now.Date.ToString(); but its text is not getting the current datetime Thanks In advance Regarda Anu Palavila

      Thanks & Regards

      D Offline
      D Offline
      darkelv
      wrote on last edited by
      #2

      ".Value"

      A 2 Replies Last reply
      0
      • A Anu Palavila

        I am with a C#.net Inventory application in one of my form there is a datetimepicker whose value my change according to some selections how can I set the datetimpicker value back to current datetime on a buttion click. I put like datetimepicker1.Text=DateTime.Now.Date.ToString(); but its text is not getting the current datetime Thanks In advance Regarda Anu Palavila

        Thanks & Regards

        V Offline
        V Offline
        Vimal Raj
        wrote on last edited by
        #3

        Hi, Try

        dateTimePicker1.Value = DateTime.Now.Date;

        . If this is not working, check whether there is any other event that is getting fired. Hope this helps,

        Happy Programming, Vimal Raj MCAD.Net www.techisolutions.blogspot.com

        1 Reply Last reply
        0
        • D darkelv

          ".Value"

          A Offline
          A Offline
          ali zaidi
          wrote on last edited by
          #4

          dateTimePicker1.Value = DateTime.Now.AddHours(-24); and 24*265 hours will be equal to one year

          1 Reply Last reply
          0
          • D darkelv

            ".Value"

            A Offline
            A Offline
            ali zaidi
            wrote on last edited by
            #5

            dateTimePicker1.Value = DateTime.Now.AddHours(-24); and 24*365 hours will be equal to one year

            C 1 Reply Last reply
            0
            • A ali zaidi

              dateTimePicker1.Value = DateTime.Now.AddHours(-24); and 24*365 hours will be equal to one year

              C Offline
              C Offline
              Christian Graus
              wrote on last edited by
              #6

              ali zaidi wrote:

              and 24*365 hours will be equal to one year

              No.....

              Christian Graus Please read this if you don't understand the answer I've given you. If you're still stuck, ask me for more information.

              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