234 lines
6.8 KiB
VB.net
234 lines
6.8 KiB
VB.net
Imports System.Drawing
|
|
Public Class MyTextBox
|
|
|
|
Enum Inputtype
|
|
전부 = 1
|
|
숫자 = 2
|
|
문자 = 3
|
|
소문자 = 5
|
|
대문자 = 6
|
|
숫자대문자 = 7
|
|
숫자소문자 = 8
|
|
End Enum
|
|
|
|
Dim ColName As String
|
|
Dim Coltype As OleDbType = OleDbType.VarChar
|
|
Dim Ditem As Boolean
|
|
Dim Prompt As String
|
|
Dim WhereState As String = vbNullString
|
|
Dim NotNull As Boolean = False
|
|
Dim iNTYPE As Inputtype = Inputtype.전부
|
|
Dim DEF_VALUE As String = Me.Text
|
|
|
|
Protected Var_ViewColNumber As Short
|
|
Protected Var_BaseLabel As Label
|
|
|
|
Public Sub New()
|
|
|
|
' 이 호출은 디자이너에 필요합니다.
|
|
InitializeComponent()
|
|
|
|
' InitializeComponent() 호출 뒤에 초기화 코드를 추가하십시오.
|
|
|
|
End Sub
|
|
|
|
<System.ComponentModel.Description("이 컨트롤과 연결된 문자를 나타낼 레이블을 선택합니다")> _
|
|
Public Property DB_BaseLabel() As Label
|
|
Get
|
|
Return Var_BaseLabel
|
|
End Get
|
|
Set(ByVal value As Label)
|
|
'//데이터가 들어오면 현재의 프롬프트를 갱신합니다.
|
|
Var_BaseLabel = value
|
|
Me.DB_Prompt = Prompt
|
|
End Set
|
|
End Property
|
|
|
|
|
|
<System.ComponentModel.Description("입력되는 값을 필터링합니다")> _
|
|
Public Property WHERE_DEFAULT_VALUE() As String
|
|
Get
|
|
Return DEF_VALUE
|
|
End Get
|
|
Set(ByVal value As String)
|
|
DEF_VALUE = value
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("입력되는 값을 필터링합니다")> _
|
|
Public Property Input_type() As Inputtype
|
|
Get
|
|
Return iNTYPE
|
|
End Get
|
|
Set(ByVal value As Inputtype)
|
|
iNTYPE = value
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("반드시입력되어야 할 값입니까?")> _
|
|
Public Property DB_NotNull() As Boolean
|
|
Get
|
|
Return NotNull
|
|
End Get
|
|
Set(ByVal value As Boolean)
|
|
NotNull = value
|
|
End Set
|
|
End Property
|
|
|
|
|
|
<System.ComponentModel.Description("검색그룹에 있을시 WHere 절")> _
|
|
Public Property DB_WhereType() As String
|
|
Get
|
|
Return WhereState
|
|
End Get
|
|
Set(ByVal value As String)
|
|
WhereState = value
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("컬럼의 설명")> _
|
|
Public Property DB_Prompt() As String
|
|
Get
|
|
Return IIf(Prompt Is vbNullString, DB_ColName, Prompt)
|
|
End Get
|
|
Set(ByVal value As String)
|
|
'//프롬프트가 바뀔때 연결된 레이블이 잇으면 텍스트를 바꿔준다.
|
|
Prompt = value
|
|
Try
|
|
Me.DB_BaseLabel.Text = value '& "(&" & Var_ViewColNumber & ")"
|
|
Catch ex As Exception
|
|
|
|
End Try
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("바인딩될 데이터베이스 컬럼명")> _
|
|
Public Property DB_ColName() As String
|
|
Get
|
|
If ColName = "" Then
|
|
Return Me.Name
|
|
Else
|
|
Return ColName
|
|
End If
|
|
End Get
|
|
Set(ByVal value As String)
|
|
ColName = value
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("연결될 데이터베이스 데이터형식")> _
|
|
Public Property DB_Type() As OleDbType
|
|
Get
|
|
Return Coltype
|
|
End Get
|
|
Set(ByVal value As OleDbType)
|
|
Coltype = value
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("데이터베이스와 연결될 아이템인가?")> _
|
|
Public Property DB_ITEM() As Boolean
|
|
Get
|
|
Return Ditem
|
|
End Get
|
|
Set(ByVal value As Boolean)
|
|
Ditem = value
|
|
End Set
|
|
End Property
|
|
|
|
<System.ComponentModel.Description("현재 값을 설정하거나 가져옵니다")> _
|
|
Public Property Value() As String
|
|
Get
|
|
If Me.DB_Type = OleDbType.Numeric AndAlso Me.Text.Trim = "" Then
|
|
Return 0
|
|
End If
|
|
Return Me.Text
|
|
End Get
|
|
Set(ByVal value As String)
|
|
If value.ToUpper = "$$DATE$$" Then
|
|
Me.Text = Format(Now, "yyyyMMdd")
|
|
Else
|
|
Me.Text = value
|
|
End If
|
|
|
|
End Set
|
|
End Property
|
|
|
|
Private Sub TextBox_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs)
|
|
If Me.Text.Length > 0 Then
|
|
Me.SelectAll()
|
|
End If
|
|
End Sub
|
|
|
|
Private Sub TextBox_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs)
|
|
Select Case iNTYPE
|
|
Case Inputtype.대문자
|
|
If Char.IsNumber(e.KeyChar) Then
|
|
e.Handled = True
|
|
Else
|
|
e.KeyChar = Char.ToUpper(e.KeyChar.ToString)
|
|
End If
|
|
'If Not Char.IsUpper(e.KeyChar.ToString) Then e.Handled = True
|
|
Case Inputtype.문자
|
|
If Char.IsNumber(e.KeyChar) Then e.Handled = True
|
|
' If Not Char.IsLetter(e.KeyChar.ToString) Then e.Handled = True
|
|
|
|
Case Inputtype.소문자
|
|
If Char.IsNumber(e.KeyChar) Then
|
|
e.Handled = True
|
|
Else
|
|
e.KeyChar = Char.ToLower(e.KeyChar.ToString)
|
|
End If
|
|
'If Not Char.IsLower(e.KeyChar.ToString) Then e.Handled = True
|
|
Case Inputtype.숫자
|
|
|
|
If Char.IsLetter(e.KeyChar) Then e.Handled = True
|
|
|
|
Case Inputtype.숫자대문자
|
|
e.KeyChar = Char.ToUpper(e.KeyChar.ToString)
|
|
|
|
Case Inputtype.숫자소문자
|
|
e.KeyChar = Char.ToLower(e.KeyChar.ToString)
|
|
|
|
End Select
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub TextBox_KeyUp(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs)
|
|
If e.KeyCode = Keys.Enter OrElse e.KeyCode = Keys.Down Then SendKeys.Send("{TAB}")
|
|
|
|
'If e.KeyCode = Keys.Right AndAlso Me.SelectionStart = Me.Text.Length Then '//오른쪽버튼일경우에는 현재커서위치가 마지막인상태에서 눌럿을때이다.
|
|
'SendKeys.Send("{TAB}")
|
|
'End If
|
|
|
|
If (e.Shift AndAlso e.KeyCode = Keys.Enter) OrElse e.KeyCode = Keys.Up Then
|
|
SendKeys.Send("+{TAB}")
|
|
End If
|
|
|
|
'If e.KeyCode = Keys.Left AndAlso Me.Text.Length <= 0 Then
|
|
' SendKeys.Send("+{TAB}")
|
|
' End If
|
|
|
|
'If e.KeyCode = Keys.Left AndAlso Me.SelectionStart = 0 Then
|
|
' SendKeys.Send("+{TAB}")
|
|
' End If
|
|
|
|
|
|
|
|
End Sub
|
|
|
|
Private Sub TextBox_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs)
|
|
Me.BackColor = IIf(Me.ReadOnly, Color.Gray, Color.White)
|
|
If Me.NotNull = True AndAlso Me.Text = "" Then
|
|
Me.ErrorProvider1.SetError(Me, "이 필드는 반드시 입력되어야합니다")
|
|
Me.BackColor = Color.Tomato
|
|
Else
|
|
Me.ErrorProvider1.Clear()
|
|
Me.BackColor = IIf(Me.ReadOnly, Color.Gray, Color.White)
|
|
'Me.BackColor = Color.White
|
|
End If
|
|
|
|
End Sub
|
|
End Class
|