2008年6月24日 星期二

以Enter事件改變作用中TextBox的顏色及字體大小

image

Public Class Form1
    Private Sub textBox1_Enter(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Enter
        TextBox1.ForeColor = Color.Yellow
        TextBox1.BackColor = Color.Blue
        TextBox1.Font = New Font("Arial", 12)
    End Sub

    Private Sub textBox1_Leave(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Leave
        TextBox1.ForeColor = Color.Black
        TextBox1.BackColor = Color.White
        TextBox1.Font = New Font("Arial", Me.Font.Size)
    End Sub

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        TextBox1.TabIndex = 1
    End Sub
End Class

沒有留言: