|
-
Oct 30th, 2006, 11:04 AM
#1
Thread Starter
Lively Member
Select Text TextBox
Hello,
Is possible when thorn with stylus (Pocket PC) upon a TextBox selects the text? I have tried with the GotFocus Event and SelectAll method but does not work. Also I found a code in this forum but it does not work either
Some solution?
VB Code:
Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click
Dim txtHold As TextBox = CType(sender, TextBox)
For intBeg As Int32 = (txtHold.SelectionStart * -1) To 0
If Math.Abs(intBeg) = txtHold.Text.Length Then
'Beyond the length of the string, nothing selected.
ElseIf txtHold.Text.Substring(Math.Abs(intBeg), 1) = " " Then
txtHold.SelectionStart = Math.Abs(intBeg) + 1
txtHold.SelectionLength = selLen(txtHold, intBeg)
Exit For
ElseIf intBeg = 0 Then
txtHold.SelectionStart = intBeg
txtHold.SelectionLength = selLen(txtHold, intBeg)
End If
Next intBeg
End Sub
Private Function selLen(ByRef txtHold As TextBox, ByVal intBeg As Int32) As Int32
For intEnd As Int32 = txtHold.SelectionStart + 1 To txtHold.Text.Length
If txtHold.Text.Substring(intEnd, 1) = " " Then
Return (intEnd - txtHold.SelectionStart)
Exit For
ElseIf intEnd = txtHold.Text.Length - 1 Then
Return (intEnd - txtHold.SelectionStart + 1)
Exit For
End If
Next
End Function
Thank you
-
Oct 31st, 2006, 10:19 AM
#2
Re: Select Text TextBox
I'm not sure what the first sentence means. I assume 'thorn' is a typo, but I can't figure out what word it should be. Therefore, I can't quite figure out what the question is? A double tap would select all the text, are you looking for that event?
My usual boring signature: Nothing
 
-
Nov 2nd, 2006, 07:56 AM
#3
Thread Starter
Lively Member
Re: Select Text TextBox
Hello,
My English is not perfect. When I strike once with stylus, I want that it selects the text automatically.
Thank you
-
Nov 2nd, 2006, 09:40 PM
#4
Re: Select Text TextBox
Ok, that's fine. The code posted looks like it is intended to select all text from the point of click to the end of the text. It sounds like you want the single tap (click) to act the same way that the double tap works.
I'd have to test this, which I can't do today, but it looks like you'd want to modify the above code in a fashion like this:
VB Code:
Private Sub TextBox1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.Click
Dim txtHold As TextBox = CType(sender, TextBox)
txtHold.SelectionStart=0
txtHold.SelectionLength=txthold.text.length
End Sub
My usual boring signature: Nothing
 
-
Nov 9th, 2006, 01:40 PM
#5
Thread Starter
Lively Member
Re: Select Text TextBox
This code does not work, does not appear the selected text but the text works double click without events selecting
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|