Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I am using the following delegate for the ENTER event of all my textboxes on a particular form.

 

Private Sub TextBoxSelection(ByVal sender As System.Object, ByVal e As System.EventArgs)
   Dim tb As TextBox
   tb = sender
   tb.SelectionLength = tb.Text.Length
   tb.SelectionStart = 0
End Sub

 

The problem is that if I type text into a textbox, exit the box, then re-enter it, the text is not selected. The cursor is set at the 0 position as it should be, but no text is selected. HOWEVER, if I then leave the textbox and re-enter it (without making any changes) the text IS all selected. Why doesn't it happen properly the first time?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...