Take winform as an example. design two textbox controls named textbox1 and textbox2 respectively. design two button controls named btn_send and btn_get respectively.
The Code is as follows:
<Span style = "font-family: Microsoft yahei; font-size: 14px;"> private void btn_send_click (Object sender, eventargs e) {try {clipboard. settext (textbox1.text); MessageBox. show ("the text box content has been successfully copied to the clipboard! ");} Catch (exception) {MessageBox. Show (" error! ") ;}} Private void btn_get_click (Object sender, eventargs e) {string txt2 = textbox2.text; try {idataobject idata = clipboard. getdataobject (); If (idata. getdatapresent (dataformats. text) {// MessageBox. show (string) idata. getdata (dataformats. text); textbox2.text = (string) idata. getdata (dataformats. unicodetext);} else {MessageBox. show ("data in the current clipboard cannot be converted to text", "error") ;}} catch (exception) {MessageBox. show ("error") ;}}</span>
Source code download