CustomToolstripTextBox.vb

 'Programmed by    :   Rey Sean Adorio Cañeso
'Address          :   28 I.B. Upper Calarian, Zamboanga City, Philippines
'Cell No          :   +639154684127
'
'CustomToolstripTextBox.vb
'No. of Lines     :   82
'Date Modified    :   03-12-2011
'

Public Class CustomToolstripTextBox
    Inherits System.Windows.Forms.ToolStripTextBox

#Region "Variables/Objects"

    Dim change As Boolean
    Private _gotFocusColor As Color = Color.AliceBlue
    Private _lostFocusColor As Color = Color.FromKnownColor(KnownColor.Window)
    Private _searchText As String = "Search"

#End Region

#Region "Properties"

    Public Property GotFocusColor() As Color
        Get
            Return Me._gotFocusColor
        End Get
        Set(ByVal value As Color)
            Me._gotFocusColor = value
        End Set
    End Property

    Public Property LostFocusColor() As Color
        Get
            Return Me._lostFocusColor
        End Get
        Set(ByVal value As Color)
            Me._lostFocusColor = value
        End Set
    End Property

    Public Property SearchText() As String
        Get
            Return Me._searchText
        End Get
        Set(ByVal value As String)
            Me._searchText = value
        End Set
    End Property

    Public Property StartSearch() As Boolean
        Get
            Return Me.change
        End Get
        Set(ByVal value As Boolean)
            Me.change = value
        End Set
    End Property

#End Region

#Region "Events"

    Private Sub CustomToolstripTextBox_GotFocus(ByVal sender As Object, ByVal e As EventArgs) Handles Me.GotFocus
        If Me.Text = Me._searchText And Me.ForeColor = Me._lostFocusColor Then
            Me.ForeColor = Me.GotFocusColor
            Me.Text = ""
            Me.change = True
        End If
    End Sub

    Private Sub CustomToolstripTextBox_LostFocus(ByVal sender As Object, ByVal e As EventArgs) Handles Me.LostFocus
        If Me.Text = "" Then
            Me.ForeColor = Me._lostFocusColor
            Me.change = False
            Me.Text = Me._searchText
        End If

    End Sub

#End Region

End Class

Project Homepage: