Click here to Skip to main content
15,892,804 members
Home / Discussions / C#
   

C#

 
GeneralRe: FormPrinting [Sylvain] Pin
Nick Parker30-Dec-04 2:57
protectorNick Parker30-Dec-04 2:57 
GeneralRe: FormPrinting [Sylvain] Pin
| Muhammad Waqas Butt |30-Dec-04 22:26
professional| Muhammad Waqas Butt |30-Dec-04 22:26 
GeneralWinforms Help Pin
| Muhammad Waqas Butt |29-Dec-04 21:42
professional| Muhammad Waqas Butt |29-Dec-04 21:42 
GeneralRe: Winforms Help Pin
Heath Stewart30-Dec-04 6:08
protectorHeath Stewart30-Dec-04 6:08 
GeneralReturning Windows Form from Remote Application Pin
Member 139313229-Dec-04 20:17
Member 139313229-Dec-04 20:17 
GeneralRe: Returning Windows Form from Remote Application Pin
Adam Goossens30-Dec-04 1:14
Adam Goossens30-Dec-04 1:14 
GeneralHighlighting Text in IE Pin
eliea29-Dec-04 19:57
eliea29-Dec-04 19:57 
GeneralRe: Highlighting Text in IE Pin
Heath Stewart30-Dec-04 6:03
protectorHeath Stewart30-Dec-04 6:03 
Add a reference to the Microsoft.mshtml.dll assembly that should've been installed with VS.NET. If you don't see it in your list of references, then in the Add Reference dialog click the COM tab and find the "Microsoft HTML Object Library" and add that. VS.NET will automatically create an interop assembly (RCW, or Runtime Callable Wrapper) for you and reference that.

To begin, when your document is loaded cast AxWebBrowser.Document to IHTMLDocument2 (add the Microsoft.mshtml namespace to your using clauses, BTW). Now you have a reference to the HTML DOM. From there you'd do what you'd do in HTML to highlight text, only you're doing it using the actual interfaces instead of how you'd do it in JavaScript/JScript or VBScript. The script uses the HTML DOM - the very one you've referenced, so what you get is the same (and more so).

Do that, cast IHTMLDocument2.body to IHTMLBodyElement and call createTextRange to get an IHTMLTxtRange. With that keep calling findText until it returns false. Each time that string is found do something like this:
range.htmlText = @"<span style=""color:white;background-color:darkblue;"">" + range.htmlText + @"</span>";


This posting is provided "AS IS" with no warranties, and confers no rights.

Software Design Engineer
Developer Division Sustained Engineering
Microsoft

[My Articles] [My Blog]
GeneralRe: Highlighting Text in IE Pin
eliea5-Jan-05 10:30
eliea5-Jan-05 10:30 
QuestionAdd LinkLabel To Richtextbox ? Pin
WDI29-Dec-04 19:50
WDI29-Dec-04 19:50 
AnswerRe: Add LinkLabel To Richtextbox ? Pin
Heath Stewart30-Dec-04 5:49
protectorHeath Stewart30-Dec-04 5:49 
GeneralRe: Add LinkLabel To Richtextbox ? Pin
WDI30-Dec-04 22:57
WDI30-Dec-04 22:57 
GeneralRe: Add LinkLabel To Richtextbox ? Pin
Heath Stewart31-Dec-04 5:57
protectorHeath Stewart31-Dec-04 5:57 
GeneralRe: Add LinkLabel To Richtextbox ? Pin
mav.northwind1-Jan-05 1:14
mav.northwind1-Jan-05 1:14 
GeneralLineScroll Pin
Member 109769929-Dec-04 19:25
Member 109769929-Dec-04 19:25 
GeneralRe: LineScroll Pin
Heath Stewart30-Dec-04 5:42
protectorHeath Stewart30-Dec-04 5:42 
Generalextensible fields data schema Pin
ppp00129-Dec-04 19:11
ppp00129-Dec-04 19:11 
GeneralRe: extensible fields data schema Pin
Heath Stewart30-Dec-04 5:45
protectorHeath Stewart30-Dec-04 5:45 
GeneralRe: extensible fields data schema Pin
ppp00130-Dec-04 15:22
ppp00130-Dec-04 15:22 
GeneralRe: extensible fields data schema Pin
Heath Stewart30-Dec-04 19:59
protectorHeath Stewart30-Dec-04 19:59 
GeneralRegional Setting Pin
Kyaw Soe Khaing29-Dec-04 18:48
Kyaw Soe Khaing29-Dec-04 18:48 
GeneralRe: Regional Setting Pin
Paul Watson29-Dec-04 21:42
sitebuilderPaul Watson29-Dec-04 21:42 
Generalsetting a font Pin
Tyrus18229-Dec-04 18:27
Tyrus18229-Dec-04 18:27 
GeneralRe: setting a font Pin
leppie29-Dec-04 23:21
leppie29-Dec-04 23:21 
General.net Remoting Pin
Anil_gupta29-Dec-04 18:21
Anil_gupta29-Dec-04 18:21 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.