Text box focus without font white on black

J

John F

I have a form that contains two controls, a large text box and a command
button to close the form. When the form is opened, the text box has focus
and all the text is selected with the font in white and a black background.
The user must click in the text box to make the text black font on a white
background, more readable, in my opinon.

I would like to have the form open without requiring the user to click in
the text box, i.e. with the text already in black font on a white background.
I can provide initial focus on the command button, which will have the
desired effect, but the problem with that is the vertical scroll bar in the
text box does not appear if the text box does not have focus. Not showing
the scroll bars could lead the user to not realize more text existed if there
was no click in the text box.

One possible approach is to programmatically trigger a mouse click in the
text box to deselect the text. Is there a better way, and if not, can
someone tell me how to programmatically trigger a mouse click event in the
text box.

Thanks,

John
 
G

GeoffG

Set the SelLength property of the TextBox to zero in the
TextBox's GotFocus event procedure, like this:

Private Sub txtField1_GotFocus()
Me.txtField1.SelLength = 0
End Sub

Don't forget to select [Event Procedure] in the "On Got Focus"
event property.

Geoff
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top