I have strange problem with coping text into clipboard. I want to copy text from textbox with additional formatting. In order to do that I intercept KeyDown event on textbox and I check if keys CTRL and C are pressed. Then I do sth like that
string extraFormatedText = formatText(txtBox.Text);
Clipboard.SetText(extraFormatedText, TextDataFormat.Text);
Function formatText adds couple of empty additional lines in text. However if I paste this text into notepad there is no additional formatting. Why is that ??
If I call function Clipboard.GetText()
I can clearly see that in returned string there are extra characters ( \n \r).
\r
represents a carriage return and\n
a newline (linefeed) character.The method
formatText
must be adding these to the end of the string.Also, the program Notepad has no formatting functionality such as bold or italic, it simply displays everything in the chosen font, size and style.