In Focus
ANNOUNCEMENT: New Features Launched on C# Corner
Jabalpur Chapter - Windows 8 Developers Day
Delhi Chapter Hands On June 22: Limited Seats Register Now
Email :
Password :
Remember me?
Forgot password
Technologies
Monthly Leaders
ASK A QUESTION
C# Programming
Multi-threading
Microsoft Surface
Community Services
Java
.NET General
Office Interoperability
ReFS
Current Affairs
JQuery
Active Directory
Printing
Silverlight 5
Fun and Jokes
JSP
ADO.NET & Database
Project Management
WCF
Job Opportunities
Multimedia, Graphics, Flash
AJAX & Atlas
Remoting
Windows 8
Leadership
PHP
Algorithms & AI
Reporting
Windows Azure
Mac for Windows
Social Networking
Arrays & Collections
Robotics and Hardware
Windows Store Apps
Microsoft Feedback
TypeScript
ASP.NET & Web Development
Security & Cryptography
Workflow Foundation
Open Source Projects
Web Hosting
C# Language
Setup & Deployment
WPF
Operating Systems
Website Management
C# References
Sharepoint
XAML Language
Paid Projects
Windows Azure
CLR & .NET Internals
Speech & Voice Recognition
Site and Forums Feedback
Prizes, Awards, MVP
Windows Phone 7
COM Interoperability
Tablet PC
Announcements
Students & Beginner Projects
Database
Custom Controls
Testing and QA
Author Guidelines
Test Category
Database General
Design and Architecture
Visual Basic .NET
Bugs and Problems
Training & Certification
Oracle
Embedded Development
Visual C++
Forums Feedback
Web Development
SQL
Enterprise Development
Visual Studio 11
Site Feedback & Suggestions
Advertising, Marketing, SEO
SQL Server
Games, DirectX, and XNA
Visual Studio 2010
Site Spams
Android
Products
GDI+ and DirectX
Web Services
Miscellaneous
Cloud Computing
Office 2013
General
Windows Forms
.NET Books
Expression Tools
Products
LINQ
Windows Services
Ask the Author
HTML 5
SharePoint 2013
Migrating to .NET
Cutting-Edge
Career Advice
HTML, JavaScript, CSS
Windows 8
Mobile Development
.NET 5.0
Coffee, Chai Lounge
iPhone, iPad
Forum guidelines
Home
»
Windows Forms
»
How to search the text in WebBrowser Control
Author
Question
V G S Naidu A
How to search the text in WebBrowser Control
Posted on: 20 Dec 2012
exceldocumentsavedas.rar
Hai,
we have a requirement like previewing the documents as like in windows7/vista
"
preview Pane
" and have to implement the
search
functionality in Winforms.For that,
I have loaded the Ms office docuemnts, and Excel Sheets and Power Point documents into
Webbrowser
Control in html format.Now we need to implement the search functionality in that webbrowser Control.
For that we have implemented the search functionality using the following code
public bool FindNext(string text, WebBrowser webBrowser1)
{
IHTMLDocument2 doc = webBrowser1.Document.DomDocument as IHTMLDocument2;
IHTMLSelectionObject sel =doc.selection;// (IHTMLSelectionObject)doc.selection;
IHTMLTxtRange rng = sel.createRange() as IHTMLTxtRange;
rng.collapse(false); // collapse the current selection so we start from the end of the previous range
if (rng.findText(text, 1000000, 0))
{
rng.select();
return true;
}
else
FindFirst(text, webBrowser1);
return false;
}
This code is working fine for searching the string values in
word Document
for all the occurences.
But when it Comes to
Excel and PPt
documents this code doesn't work properly.it finds only the first occurrence of the string other occurrences doesn't find.
while debugging i found that,for word Documents "IHTMLDocument2" object stores the html Content in "innerHTML" and "innerText" with some values.
But for Excel it stores the text in "innerHTML" only by using the Frames, and sheets are referenced to local temporary .html files and it didn't have any "innerText" content it showing as null.
Please provide the solution to search the text in webbrowser control which loaded the html content, that is converted from Excel,PPT to html type and displaying in webbrowser control.
If you have any queries please feel to ask me.
Thank You.
V G S Naidu
Reply
Quick Reply
Report a Spam
Our Recommended Solutions
WebBrowser Control in C# and Windows Forms
Find and Replace for Multiline Text
Type-Ahead Text Searching in Silverlight 5 Beta
WebBrowser Control - Scripting Support [Video 7/7]
Creating Full Text Index in SQL Server
How to Use Full Text Search in SQL Server 2008
Full Text Indexing in SQL Server 2012
Word Processing with an Extended Rich Text Box Control
Introduction to Web Site Scraping
How to Embed HTML File in Windows Phone 7
[ + ]
Quick Reply:
SEARCH ANSWERS
All
C# Programming
Cutting-Edge
Site and Forums Feedback
Miscellaneous
Web Development
Database
Products
Any Word
Exact Word
Our recommended forum posts
c# project related problem
Default value for Multiple TextBoxes in C#
C# Custom Control Handling
How to resize the controls(eg.button,textbox) in windows app
search quarie.. selected two coloums in table?
How to get Row data from Jqgrid to another view/Controller
How to transfer a file from my pc to server..
My ajax EditorControl not working at production environment
search user profile
online user total user count
HOT QUESTIONS
c# writing user input from form to text file using windows a
Import/Export Generic List Objects
System.Collection.IList
Create List accessible for other classes
Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)
Extracting Data from a listbox in Another Application
mathematical euation
code is not working
how can i locate a webbrowser control
Congratulation Vinod Kumar
SPONSORED BY
DynamicPDF ReportWriter Suite
PDF reports have never been easier to create. With our included WYSIWYG Designer, you can layout your reports, set up your data source and let DynamicPDF ReportWriter do the rest.