开发者

Manipulating the calendar in vb.net

开发者 https://www.devze.com 2023-03-28 09:12 出处:网络
I\'m currently creating an auction website using asp and vb.net. I want to manipulate the calendar s开发者_运维技巧o that only dates after the current date are selectable. How can I go about this? Tha

I'm currently creating an auction website using asp and vb.net. I want to manipulate the calendar s开发者_运维技巧o that only dates after the current date are selectable. How can I go about this? Thanks


You'll have to do it manually, I think. If the user selects an earlier date (you can gauge this with the "Changed" event), you can restore it to the current date and give an error message.

For example (in regular VB.NET)

Private Sub DateTimePicker1_ValueChanged(sender As System.Object, e As System.EventArgs) Handles     DateTimePicker1.ValueChanged
         If DateTimePicker1.Value < Now Then
            DateTimePicker1.Value = Now
            MsgBox("Error!")
         End If
    End Sub

Or, more directly, using the MinDate property of the control:

dateTimePicker1.MinDate = DateTime.Today
0

精彩评论

暂无评论...
验证码 换一张
取 消