复制:
ym4nmA-T/mL(c"q3Sq0private void button1_Click(object sender, System.EventArgs e) {
2\9eu6\6SM0 // Takes the selected text from a text box and puts it on the clipboard.
u:ixpoxYj1@0 if(textBox1.SelectedText != ”")ITPUB个人空间;sq-_\&_!K+]uV,zT
Clipboard.SetDataObject(textBox1.SelectedText);
1hP A&Lj+DU0 }
粘贴:
E XI)udUZ0private void button2_Click(object sender, System.EventArgs e) {ITPUB个人空间;W|5G1ENs'S
// Declares an IDataObject to hold the data returned from the clipboard.ITPUB个人空间 LQX j;SX
// Retrieves the data from the clipboard.ITPUB个人空间PY:k i0K)C8[6KF7Q
IDataObject iData = Clipboard.GetDataObject();
.OGWc#p0
$w?&o3OI#deY0 // Determines whether the data is in a format you can use.
+tAE1B Q,T?kP0 if(iData.GetDataPresent(DataFormats.Text)) {
9D/NS"W*Tu%Ct0 // Yes it is, so display it in a text box.
8teicY p$A0 textBox2.Text = (String)iData.GetData(DataFormats.Text);
I;O?e2t5ul h-_"o0 }ITPUB个人空间/D3D.MY!d;~
}
5o?$@YT h.\0主要通过调用Clipborad的API完成。