C # operating system clipboard

xiaoxiao2021-03-06  39

The clipboard is one of the most common functions in the Windows operating system, which is used to pass data from one application to another, which can be text, images, and even program objects. However, the clipboard also has restrictions, which can only point to a piece of content at a certain time, and each subsequent copying content will replace the previous content. In order to operate the clipboard (including reading and writing) in the C #, you need to use the System.Windows.Forms.clipboard class. Let's first describe how to write data to the clipboard in an example. Let's take a look at the operation: As shown above, you can enter some text in the text box then click to copy the button, then the program writes the data in the text box to the clipboard, then open the notepad Lower Ctrl V key, is it to see the data that has just been entered in the text box? The code is as follows: private void button1_click (object sender, system.eventargs e) {// exit button close ();} // copy button, private void button2_click (object sender, system.eventargs e) {if (THIS.TEXTBOX1 .Text == "") {MessageBox.show ("Copy must be input before"); return;} Else // setDataObject (Object Obj, Bool Copy) Method to place the data on the clipboard // parameter Obj refers to data object // parameter COPY means that the data is still saved on the clipboard at clipboard.setDataObject (THISTEXTBOX1.TEXT, TRUE);} How to write data in the clipboard when the program exits. Next, let's take a look at how to read the contents in the clipboard in the program, so let's take a look at the operation of the program: Program Components: New Windows programs, put 3 Button and 1 Label and 1 on the form Picturebox.

转载请注明原文地址:https://www.9cbs.com/read-66734.html

New Post(0)