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. Visual Basic
  4. DateTimePicker - VB

DateTimePicker - VB

Scheduled Pinned Locked Moved Visual Basic
help
6 Posts 6 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
    aaraaayen
    wrote on last edited by
    #1

    Hi Friends, I am using DateTimePicker in my page. But I want that datetimepicker control should be enabled for only current month and when we select previous or next month it should be disabled. Please help me for this. Regards,

    A L A D 4 Replies Last reply
    0
    • A aaraaayen

      Hi Friends, I am using DateTimePicker in my page. But I want that datetimepicker control should be enabled for only current month and when we select previous or next month it should be disabled. Please help me for this. Regards,

      A Offline
      A Offline
      Anoop Brijmohun
      wrote on last edited by
      #2

      What you will need to do is to write some code within the selecteddate changed event. you should check the datetiempicker selecteddate vs system date...do a month comparison and then set the dtp.enabled to true/false. hope this helps

      1 Reply Last reply
      0
      • A aaraaayen

        Hi Friends, I am using DateTimePicker in my page. But I want that datetimepicker control should be enabled for only current month and when we select previous or next month it should be disabled. Please help me for this. Regards,

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #3

        Try this code Private Sub DateTimePicker1_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DateTimePicker1.ValueChanged If Not (DateTimePicker1.Value.Month = Now.Month AndAlso DateTimePicker1.Value.Year = Now.Year) Then DateTimePicker1.Enabled = False Else DateTimePicker1.Enabled = True End If End Sub

        1 Reply Last reply
        0
        • A aaraaayen

          Hi Friends, I am using DateTimePicker in my page. But I want that datetimepicker control should be enabled for only current month and when we select previous or next month it should be disabled. Please help me for this. Regards,

          A Offline
          A Offline
          akash_omsairam
          wrote on last edited by
          #4

          For displaying current month in vb.net we use Month(ToDay) It display current month only :-D

          1 Reply Last reply
          0
          • A aaraaayen

            Hi Friends, I am using DateTimePicker in my page. But I want that datetimepicker control should be enabled for only current month and when we select previous or next month it should be disabled. Please help me for this. Regards,

            D Offline
            D Offline
            Dave Kreskowiak
            wrote on last edited by
            #5

            If you're talking about the ASP.NET (Web Forms) version of the control, you can set the MinDate and MaxDate properties to limit the range the user can select from.

            A guide to posting questions on CodeProject[^]
            Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                 2006, 2007

            M 1 Reply Last reply
            0
            • D Dave Kreskowiak

              If you're talking about the ASP.NET (Web Forms) version of the control, you can set the MinDate and MaxDate properties to limit the range the user can select from.

              A guide to posting questions on CodeProject[^]
              Dave Kreskowiak Microsoft MVP Visual Developer - Visual Basic
                   2006, 2007

              M Offline
              M Offline
              Mycroft Holmes
              wrote on last edited by
              #6

              Same for winforms

              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