Code: Select all
With txtItem
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
Alan
Code: Select all
With txtItem
.SetFocus
.SelStart = 0
.SelLength = Len(.Text)
End With
Code: Select all
Private Sub txtItem_Enter()
With Me.txtItem
.SelStart = 0
.SelLength = Len(.Text)
End With
End Sub
Code: Select all
Private Sub txtItem_MouseDown(ByVal Button As Integer, ByVal Shift As Integer, ByVal X As Single, ByVal Y As Single)
With Me.txtItem
.SelStart = 0
.SelLength = Len(.Text)
End With
End Sub
Yes, that's what one would logically expect, but unfortunately it doesn't work for all events... hence the workaround. As Hans says, if the user tabs to the control it works, but not if the text within is clicked with the mouse.Jan Karel Pieterse wrote:A textbox has a property called EnterFieldBehavior, which determines whether or not all text is selected when the textbox gains focus. Set it to 0 - fmEnterFieldBehaviorSelectAll to have it -well- select all.