Results 1 to 8 of 8

Thread: [RESOLVED] [2005] highlight certain text in textbox without getting focus (firefox-like search)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    Resolved [RESOLVED] [2005] highlight certain text in textbox without getting focus (firefox-like search)

    i want to do something like firefox search mechanism where you type your text in the search box, on the webpage.. the text searched is highlighted.... i tried it on vb 2005 but i must always get focus to highlight a text..so i lose focus for my search textbox

  2. #2
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Sector 001
    Posts
    1,577

    Re: [2005] highlight certain text in textbox without getting focus (firefox-like search)

    The property HideSelection should be set to false.
    VB 2005, Win Xp Pro sp2

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    Re: [2005] highlight certain text in textbox without getting focus (firefox-like search)

    wa!!! thanks

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    Re: [RESOLVED] [2005] highlight certain text in textbox without getting focus (firefox-like search)

    how can i make it autoscroll to location where text is highlighted???

  5. #5
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Sector 001
    Posts
    1,577

    Re: [RESOLVED] [2005] highlight certain text in textbox without getting focus (firefox-like search)

    How are you highlighting the text? I just tried it with RichTextBox.Select and it jumps right away to the selected text.
    VB 2005, Win Xp Pro sp2

  6. #6

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    Re: [RESOLVED] [2005] highlight certain text in textbox without getting focus (firefox-like search)

    i use a regular textbox.... i am using text1.selectionstart and text1.selectionlength

    will try with a richboxtext but do u know how to do it with a textbox?

  7. #7
    Frenzied Member
    Join Date
    Mar 2005
    Location
    Sector 001
    Posts
    1,577

    Re: [RESOLVED] [2005] highlight certain text in textbox without getting focus (firefox-like search)

    That is a pain. Use textbox.scrolltocaret.

    If you need the caret somewhere else, you move it by using TextBox.Select(start of the selection, 0). To make it complicated, first you assign the original selection start and selection length to some backup integer variables, then use:
    to move the caret: TextBox.Select(start of the selection, 0)
    to scroll there: TextBox.scrolltocaret
    to restore the selection: TextBox.Select(original start, original length)

    Instead of text1.selectionstart and text1.selectionlength, you can use TextBox.Select(Start as Integer, Length as Integer) as I just did. It doesn't seem to be documented in MSDN but it works. It could be legacy issue, in that case text1.selectionstart and text1.selectionlength are the better choice.
    VB 2005, Win Xp Pro sp2

  8. #8

    Thread Starter
    Addicted Member
    Join Date
    Jan 2007
    Posts
    128

    Re: [RESOLVED] [2005] highlight certain text in textbox without getting focus (firefox-like search)

    lol i will switch to richtext box instead thanks very much

Posting Permissions

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



Click Here to Expand Forum to Full Width