Change Label foreground and background colout
Posted on 2005-05-04
I have a problem with some coding in a simple form based app.
What I am trying to do is have a lebel text and background change colours and text to indicate what the app is doing. (code samples below)
part of my code is:
Private Sub txtName_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtName.KeyPress
If e.KeyChar = Chr(13) Then
searching() : Lookup()
Else : status_restart()
The lookup function works ok, but the searching part (below does not) in the same event.
Public Function searching()
lblStatus.Text = "Searching...."
lblStatus.BackColor = System.Drawing.Color.Red
lblStatus.ForeColor = System.Drawing.Color.White
to get around the problem when using a mouse, I use the mousedown event for a button called query to call searching(), and the mouse buttonclick event to call the lookup() function.
Any ideas as to why I need two events and is there a solution?
Note - I am a great fan of using the keyboard as we can process so much quicker.