Public Class Readdtpkr
Inherits
DateTimePicker
Public Sub New()
If
_ReadOnly Then
Me.Value
= _LockedDate
End If
End Sub
Dim
_LockedDate As Date
= Today
Public Property LockedDate() As
Date
Get
Return
_LockedDate
End Get
Set(ByVal value As Date)
If value
<= MaxDate AndAlso value >= Me.MinDate Then
_LockedDate = value
Me.Value
= value
Else
Throw
New System.Exception("Bad
Locked Date Value")
End
If
End Set
End Property
Dim
_ReadOnly As Boolean
= True
Public Property [ReadOnly]() As
Boolean
Get
Return
_ReadOnly
End Get
Set(ByVal value As Boolean)
_ReadOnly = value
End Set
End Property
Private Sub ReadOnlyDateTimePicker_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles Me.KeyPress
If
_ReadOnly Then
e.Handled = True
End If
End Sub
Private Sub ReadOnlyDateTimePicker_ValueChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles
Me.ValueChanged
If
_ReadOnly Then
Me.Value
= _LockedDate
End If
End Sub
End Class
No comments:
Post a Comment