Search code examples
c#.netclipboardcopy-paste

How to copy the contents of a Multiline textbox to the clipboard in C#?


I have some text coming from database in a Multiline textbox, how can I copy that to the clipboard so that the user can paste it into another window or file (e.g. from my application to another textbox)? OR to notepad/word file if possible.


Solution

  • Clipboard.Clear();    //Clear if any old value is there in Clipboard        
    Clipboard.SetText("abc"); //Copy text to Clipboard
    string strClip = Clipboard.GetText(); //Get text from Clipboard