TextBox selection problem-VBForums
Results 1 to 1 of 1

Thread: TextBox selection problem

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Dec 2011
    Posts
    168

    TextBox selection problem

    I'm developing an app for Windows Phone 8.1 and having problem to select text correctly. There is a MultiLine TextBox when i search for word, i highlight it, the problem is that, highlighting works perfect if the word is in first line but if it is in the second line, the highlight shifted to left one character and if it is in the third line, the highlight shifted to left two characters
    EX:
    if TextBox text is
    Code:
    aaa-aaa-
    aaa-aaa-
    aaa-aaa-
    and search for "aaa", tapping on Find Next button produce the following highlighting sequence

    Code:
    aaa-aaa-
    aaa-aaa-
    aaa-aaa-
    Code:
    aaa-aaa-
    aaa-aaa-
    aaa-aaa-
    Code:
    aaa-aaa-
    aaa-aaa-
    aaa-aaa-
    Code:
    aaa-aaa-
    aaa-aaa-
    aaa-aaa-
    As you can see, the highlighting continue shift to the right for each new line

    Here is my code
    Code:
        Private mstrSearch As String = "aaa"
        Private mintIndex As Integer = -1
    
        Private Sub btnSearch_Click(sender As Object, e As RoutedEventArgs)
    
            mintIndex = txtMain.IndexOf(mstrSearch, mintIndex + 1)
            If mintIndex >= 0 Then
                txtMain.Focus(FocusState.Programmatic)
                txtMain.SelectionStart = mintIndex
                txtMain.SelectionLength = mstrSearch.Length
            End If
    		
        End Sub
    Last edited by Absolute_Zero; Feb 24th, 2016 at 04:23 PM.
    On Error GoTo Hell

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.