How to set HTML to clipboard in C#?

前端 未结 4 1601
谎友^
谎友^ 2020-11-29 12:54

I want to put rich text in HTML on the clipboard so when the users paste to Word, it will include the source HTML formatting.

Using the Clipboard.SetText method does

4条回答
  •  野性不改
    2020-11-29 13:36

    Arthur is right about the header, but the important thing to note here is that the data isn't going to be on the clipboard as plain text. You have to use CF_HTML. You can read about that at MSDN: http://msdn.microsoft.com/en-us/library/aa767917(v=vs.85).aspx To be proper, you'd have a CF_TEXT showing simply: "Hello!", and then CF_HTML with the HTML header and data, as in Arthur's example.

提交回复
热议问题