Alex Gordon
Alex Gordon

Reputation: 60871

How do I paste richtext into a textbox?

I want to highlight some stuff on a web page and be able to paste it into a richtextbox in C# winforms. I want to then be able to see the HTML code of what I had pasted. Is this possible?

Upvotes: 0

Views: 308

Answers (1)

Jason Webb
Jason Webb

Reputation: 8020

This snippet will return a string containing the code. There is some header info at the top that you may want to parse out but it is pretty straight forward.

string html = Clipboard.GetData(DataFormats.Html).ToString();

You will be able to populate that into a text box or richtext box however you like.

Upvotes: 2

Related Questions