|
|
Title | Highlight the TextBox that has focus by changing its BackColor |
Description | This example shows how to highlight the TextBox that has focus by changing its BackColor in Visual Basic 6. |
Keywords | highlight, focus, GotFocus, LostFocus, TextBox |
Categories | Controls, Miscellany |
|
|
Subroutines HighlightControl and UnHighlightControl set a control's BackColor property to highlighted and non-highlighted values respectively.
|
|
Private m_FocusControl As Control
' Highlight the newly selected control.
Private Sub HighlightControl(ByVal ctl As Control)
ctl.BackColor = RGB(&HC0, &HFF, &HFF)
End Sub
' Unhighlight the newly selected control.
Private Sub UnHighlightControl(ByVal ctl As Control)
ctl.BackColor = vbWhite
End Sub
|
|
The program calls HighlightControl in each TextBox's GotFocus event handler. It calls UnHighlightControl in each TextBox's LostFocus event handler.
|
|
Private Sub txtCity_GotFocus()
HighlightControl txtCity
End Sub
Private Sub txtCity_LostFocus()
UnHighlightControl txtCity
End Sub
|
|
|
|
|
|