2 Replies - 3999 Views - Last Post: 05 November 2011 - 05:29 PM Rate Topic: -----

#1 q12   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 29
  • Joined: 12-April 09

How do I COPY the selected text from a webBrowser page?

Posted 05 November 2011 - 03:33 PM

This is a Hard question(apparently simple):
How do I COPY the selected text from a webBrowser page, and paste it to a text file( for example)?
I have this until now:


private void webBrowser1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e)
        {
//the 67 is the mousebutton no4 (I have 5 5buttons and a scrolwhell-A4Tech_X7 mouse) 
//the mousebutton no4 is set to "ctrl+c" keys (Copy) 
          if (e.KeyValue == 67)
          textBox2.Text=webBrowser1.DocumentText;
        }


Until now i cant manage to copy a text selection from webBrowser.
How to do that?
Thank you.

Is This A Good Question/Topic? 0
  • +

Replies To: How do I COPY the selected text from a webBrowser page?

#2 Martyr2   User is offline

  • Programming Theoretician
  • member icon

Reputation: 5465
  • View blog
  • Posts: 14,418
  • Joined: 18-April 07

Re: How do I COPY the selected text from a webBrowser page?

Posted 05 November 2011 - 04:15 PM

Well you can copy stuff by accessing the underlying document of the webbrowser and then executing a copy command.

private void webBrowser1_PreviewKeyDown(object sender, PreviewKeyDownEventArgs e) {
     // Access the underlying document, then execute a copy command on it.
     // This will copy the selected item to the clipboard
     webBrowser1.document.ExecCommand("COPY", false, null);
}



I assume this is what you were looking to do.

:)
Was This Post Helpful? 1
  • +
  • -

#3 q12   User is offline

  • New D.I.C Head

Reputation: -1
  • View blog
  • Posts: 29
  • Joined: 12-April 09

Re: How do I COPY the selected text from a webBrowser page?

Posted 05 November 2011 - 05:29 PM

!YES!- thats it.
Thank you very much.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1