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 _ 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 _ 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 _ Public Property Input_type() As Inputtype Get Return iNTYPE End Get Set(ByVal value As Inputtype) iNTYPE = value End Set End Property _ Public Property DB_NotNull() As Boolean Get Return NotNull End Get Set(ByVal value As Boolean) NotNull = value End Set End Property _ Public Property DB_WhereType() As String Get Return WhereState End Get Set(ByVal value As String) WhereState = value End Set End Property _ 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 _ 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 _ Public Property DB_Type() As OleDbType Get Return Coltype End Get Set(ByVal value As OleDbType) Coltype = value End Set End Property _ Public Property DB_ITEM() As Boolean Get Return Ditem End Get Set(ByVal value As Boolean) Ditem = value End Set End Property _ 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