DateTimePicker - VB
-
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,
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
-
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,
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
-
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,
For displaying current month in vb.net we use Month(ToDay) It display current month only :-D
-
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,
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 -
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, 2007Same for winforms