| Public Shared validateNone As Boolean = False
' ******************************************************
' validate コントロール用
' ******************************************************
Protected Overloads Overrides Sub OnValidating( _
ByVal e As System.ComponentModel.CancelEventArgs)
' ******************************************************
' validateNone が True ならば、Valdating は発生しない
' ******************************************************
If Not validateNone Then
If Me.Enabled = True Then
MyBase.OnValidating(e)
End If
End If
End Sub
Protected Overloads Overrides Sub OnValidated( _
ByVal e As System.EventArgs)
' ******************************************************
' validateNone が True ならば、Validated は発生しない
' ******************************************************
If Not validateNone Then
If Me.Enabled = True Then
MyBase.OnValidated(e)
End If
End If
End Sub
' ******************************************************
' 文字列としてのデータ
' ******************************************************
Public Property InnerText() As String
Get
If Not Me.Checked Then
Return ""
Else
Return Me.Value.ToString("d")
End If
End Get
Set(ByVal value As String)
Try
Me.Value = Date.Parse(value)
Catch ex As Exception
Me.Value = Date.Today
End Try
If value = "" Then
Me.Checked = False
Else
Me.Checked = True
End If
End Set
End Property
' ******************************************************
' SQL用文字列としてのデータ
' ******************************************************
Private _DbDefault As String = "NULL"
Public ReadOnly Property DbText() As String
Get
If Not Me.Checked Then
Return _DbDefault
Else
Return "'" + Me.Value.ToString("d") + "'"
End If
End Get
End Property
' ******************************************************
' SQL用デフォルトデータ
' ******************************************************
Public Property DbDefault() As String
Get
Return _DbDefault
End Get
Set(ByVal value As String)
_DbDefault = value
End Set
End Property
' ******************************************************
' カスタムチェックタイプ
' ******************************************************
Private _CheckType As Integer = 0
<System.ComponentModel.Description("0:なし" & Chr(10) & "1:必須入力"), _
System.ComponentModel.DefaultValue(0)> _
Public Property CheckType() As Integer
Get
Return _CheckType
End Get
Set(ByVal value As Integer)
_CheckType = value
End Set
End Property
' ******************************************************
' 同一処理支援
' ******************************************************
Private _Group As Integer = 1
<System.ComponentModel.DefaultValue(1)> _
Public Property Group() As Integer
Get
Return _Group
End Get
Set(ByVal value As Integer)
_Group = value
End Set
End Property
' ******************************************************
' 全体のチェック
' ******************************************************
Private Sub LboxDate_Validating(ByVal sender As System.Object, _
ByVal e As System.ComponentModel.CancelEventArgs) Handles MyBase.Validating
' 必須入力
If Me._CheckType = 1 Then
If Not Me.Checked Then
MessageBox.Show("必須入力です ", _
"エラー", MessageBoxButtons.OK, MessageBoxIcon.Error)
e.Cancel = True
End If
End If
End Sub
| |