473,406 Members | 2,894 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Selecting text in webrowser control

I am having trouble with some code that is intended to take a previously stored url and text selection within the page, open the web page in a webrowser control and then select the text.

I have the first bit working and successfully navigate to the url, but I can't find a working solution for some code in the Navigated event handler to select the text. Most of the solutions I have seen on the internet get the SelectionObject for the page and then use the Move() member but my code to get a TxtRange from the SelectionObject causes an exception as the SelectionObject initially has type = none and the createRange() method only works when type = text.

Relevant code shown below - can anyone help?

Expand|Select|Wrap|Line Numbers
  1. private void webBrowser1_Navigated(object sender, WebBrowserNavigatedEventArgs e)
  2. {
  3.             try
  4.             {
  5.                 IHTMLDocument2 htmlDocument = webBrowser1.Document.DomDocument as IHTMLDocument2;
  6.                 IHTMLSelectionObject currentSelection = htmlDocument.selection;
  7.  
  8.                 IHTMLTxtRange range = currentSelection.createRange() as IHTMLTxtRange;  // causes exception
  9.  
  10.                 range.moveToPoint(this.Start_X, this.Start_Y);
  11.  
  12.  
  13.  
Apr 23 '10 #1
0 1076

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: mike.hodgson | last post by:
Hi, I have an image in a webrowser which is 3000 pixels wide so does not fit in the browsers window. It is a CAD drawing so needs this detail. Using the scroll bars makes the image difficult to...
1
by: Ramesh | last post by:
hi, I am selecting fields from three table for manupulating data and i want to display total number of records selected. But i am always getting -1 value, eventhough 1000 of records are selected....
4
by: Paddy | last post by:
How do I select a subitem from a listview after clicking on the first column? Couldn't find it in MSDN. Thank you. Paddy.
1
by: Dave | last post by:
Hello. I have DeropDownList control on my page and want to select some value by SelectedValue, but before selecting I want to ensure that the value exists in DeropDownList control's items. How...
42
by: Dooglo | last post by:
I'm new VB and programming all together, but I'm getting he hang of it. My question is; I'm writting a program to figure square feet and yards when the user inputs "Length in feet and inch (...
1
by: Chase Gale | last post by:
Hello, I am developing a large financial application... In a section of the app I host a Microsoft Webbrowser control which connects to a bank and displays thier Java Applet. The problem I am...
2
by: Phrogz | last post by:
Years ago I wrote a library to turn normal <selectsinto text inputs that the user can type in, with various features. In those days, I was working for an IE-centric company, so I didn't spend the...
2
by: Abubakar | last post by:
Hi, In a normal Windows.Forms.TextBox control, I want to be able to select a text (ie highlight, this is by default possible) and than be able to drag that text through my mouse pointer to another...
1
by: DICKDDD | last post by:
The problem is that if you navigate the control to a page containg a flash swf object, the object will play once (suppose it has a button to do that). After it plays once it wont play again. Same...
4
by: jim | last post by:
I want to make a WYSIWYG editor for HTML pages that can detect events in the webbrowser control in real time and control the webbrowser control (and internal documents) to allow simple stuff like...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.