开发者

Include Font while pasting to Clipboard

I'm trying to include the font "KaiTi" while setting text on the clipboard, so that wherever I paste the data, the "KaiTi" Font will be the font that the text is in, inevitably keeping all of the data that I am pastin开发者_高级运维g to the clipboard formatted the way that I want it too.

This is what I tried, I know it's off, but I don't know what to do..

            TextBox texter = new TextBox();
            texter.Text = strToClips;
            texter.Font = new Font("KaiTi", 10);
            Clipboard.SetText(texter.Text);


Use a RichTextBox. It puts rich text on the clipboard that includes formatting. Use its Copy() method. Pasting back now also works automatically without any code.


The richtextbox displayed the formatting OK, but I couldn't get Copy() to bring the font across. In the end I selected the text then sent a Ctrl-C character to copy it, as follows:-

myrichtextbox.SelectAll();
myrichtextbox.Focus();
SendKeys.Send("^C");
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜