Changing the Background (color) property for all Textbox controls 
Author Message
 Changing the Background (color) property for all Textbox controls

I have a form with many normal Textbox controls.
Actually, it's so many that sometimes it's hard to
know where the insertion point is. I want to change
the color of the textbox with focus. Every time I
press the TAB key or click on another textbox, the
background color of the preceding textbox should
change to white as before, and the focused textbox
should turn to, for example, light yellow. It would
be nice to make it globally, not in the GotFocus()
and LostFocus() event of every control.

Best Regards

Gustaf Liljegren



Sat, 15 Jul 2000 03:00:00 GMT  
 Changing the Background (color) property for all Textbox controls

If you were using a control array (of textboxes), you could do "something"
like the following:

Private Sub txtText_GotFocus(Index As Integer)
    Call SetTextBackColor
End Sub

Private Sub txtText_LostFocus(Index As Integer)
    Call SetTextBackColor
End Sub

Sub SetTextBackColor( )
    Dim vText As Variant
    For Each vText In Textboxes
        vText.BackColor = IIf(vText.Index = ActiveControl.Index, vbYellow,
vbWhite)
    Next vText
End Sub

I haven't run this example through the wringer, so I won't guarantee
results; but it seems like it will work. WYSIWYG.
--
Hope this helps...

Jeffrey Renton
jrenton AT ees DOT enron DOT com



Quote:
> I have a form with many normal Textbox controls.
> Actually, it's so many that sometimes it's hard to
> know where the insertion point is. I want to change
> the color of the textbox with focus. Every time I
> press the TAB key or click on another textbox, the
> background color of the preceding textbox should
> change to white as before, and the focused textbox
> should turn to, for example, light yellow. It would
> be nice to make it globally, not in the GotFocus()
> and LostFocus() event of every control.

> Best Regards

> Gustaf Liljegren



Sat, 15 Jul 2000 03:00:00 GMT  
 Changing the Background (color) property for all Textbox controls

Quote:
Jeffrey Renton wrote...
>If you were using a control array (of textboxes), you could do "something"
>like the following:

[snip]

Yes, this was a good idea. But, as I wrote, this time
I don't want to put code in every event procedure.
This makes about 60 procedures with only one line,
as I did before:

Private Sub txtNr_LostFocus()
    txtNr.BackColor = &HFFFFFF
End Sub

It's no problem, it works, but as a perfectionist I
don't like to put the same code in 60 procedures... :-/

Best Regards

Gustaf Liljegren

Quote:


>> I have a form with many normal Textbox controls.
>> Actually, it's so many that sometimes it's hard to
>> know where the insertion point is. I want to change
>> the color of the textbox with focus. Every time I
>> press the TAB key or click on another textbox, the
>> background color of the preceding textbox should
>> change to white as before, and the focused textbox
>> should turn to, for example, light yellow. It would
>> be nice to make it globally, not in the GotFocus()
>> and LostFocus() event of every control.

>> Best Regards

>> Gustaf Liljegren



Sun, 16 Jul 2000 03:00:00 GMT  
 Changing the Background (color) property for all Textbox controls

Quote:
I wrote...
>It's no problem, it works, but as a perfectionist I
>don't like to put the same code in 60 procedures... :-/

Hoppsan! (as we say in swedish). Sorry, I misunderstood
you. Of course a control array only need 2 or 3 procedures
for this task. :-)

Best regards

Gustaf Liljegren



Sun, 16 Jul 2000 03:00:00 GMT  
 
 [ 4 post ] 

 Relevant Pages 

1. Background Color Change for Rich Textbox Control

2. How to change background color of a disabled Textbox

3. changing color on textbox background ???

4. *** HELP WITH TEXTBOX - CHANGING THE BACKGROUND COLOR AT RUNTIME ***

5. Changing Background Color of Textbox

6. Changing background color for textbox

7. Change the color of form's caption (background and font color)

8. BMP - change color based on form's background color

9. BMP - change color based on form's background color

10. Changing Cursor Size and or Color of Control Background

11. ListView Control ... changing background color of individual rows

12. toolbar control - how to change background color ?

 

 
Powered by phpBB® Forum Software