|
-
Jan 15th, 2007, 04:19 PM
#1
Thread Starter
Addicted Member
[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
-
Jan 15th, 2007, 04:26 PM
#2
Re: [2005] highlight certain text in textbox without getting focus (firefox-like search)
The property HideSelection should be set to false.
-
Jan 15th, 2007, 04:40 PM
#3
Thread Starter
Addicted Member
Re: [2005] highlight certain text in textbox without getting focus (firefox-like search)
wa!!! thanks
-
Jan 17th, 2007, 09:22 AM
#4
Thread Starter
Addicted Member
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???
-
Jan 17th, 2007, 12:08 PM
#5
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.
-
Jan 17th, 2007, 12:39 PM
#6
Thread Starter
Addicted Member
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?
-
Jan 17th, 2007, 01:08 PM
#7
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.
-
Jan 17th, 2007, 02:38 PM
#8
Thread Starter
Addicted Member
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|