C
Carl Imthurn
I have a combo box that, when the user clicks on the text area of it, I want the text to become selected.
Here's my code:
Private Sub cboSelectAClinic_GotFocus()
MsgBox "running the GotFocus event"
cboSelectAClinic.SelStart = 0
cboSelectAClinic.SelLength = Len(cboSelectAClinic.Text)
End Sub
Here's what happens:
When I select one of the combo box entries via the drop down functionality, everything works fine -- the text portion becomes selected. Then, naturally, as soon as I hit <tab> or click somewhere else on the form, it becomes unselected.
So far so good.
The user then clicks up in the text area of the combo box and it does *not* select the existing text -- the cursor is merely positioned in the text area of the combo box. The user can, of course, manually select the whole text area and start typing, but
that is exactly what I was hoping to accomplish with the above code.
When the user clicks in the text area, the msgbox appears, so the event is definitely firing, but simply not doing what I believe it should be doing . . .
I've tried a number of things without success, including:
cboSelectAClinic.SelLength = 17 ' hard-coding the length of this particular combo box entry -- same result as above
cboSelectAClinic.SelStart = Len(cboSelectAClinic.Text) ' same result as above
using the Enter event instead
Pounding on the keyboard with my fists
Bashing my head against the monitor
What am I missing?
Thanks in advance --
Carl
Here's my code:
Private Sub cboSelectAClinic_GotFocus()
MsgBox "running the GotFocus event"
cboSelectAClinic.SelStart = 0
cboSelectAClinic.SelLength = Len(cboSelectAClinic.Text)
End Sub
Here's what happens:
When I select one of the combo box entries via the drop down functionality, everything works fine -- the text portion becomes selected. Then, naturally, as soon as I hit <tab> or click somewhere else on the form, it becomes unselected.
So far so good.
The user then clicks up in the text area of the combo box and it does *not* select the existing text -- the cursor is merely positioned in the text area of the combo box. The user can, of course, manually select the whole text area and start typing, but
that is exactly what I was hoping to accomplish with the above code.
When the user clicks in the text area, the msgbox appears, so the event is definitely firing, but simply not doing what I believe it should be doing . . .
I've tried a number of things without success, including:
cboSelectAClinic.SelLength = 17 ' hard-coding the length of this particular combo box entry -- same result as above
cboSelectAClinic.SelStart = Len(cboSelectAClinic.Text) ' same result as above
using the Enter event instead
Pounding on the keyboard with my fists
Bashing my head against the monitor
What am I missing?
Thanks in advance --
Carl