IDataObjectd=Clipboard.GetDataObject();d为空但是按Ctrl+V还能把东西复制出来,什麼原因...
IDataObject d = Clipboard.GetDataObject ( ) ; d为空但是按Ctrl+V还能把东西复制出来,什麼原因
private void Form1_Load(object sender, EventArgs e)
{
Clipboard.SetDataObject("aaa");
}
private void button1_Click(object sender, EventArgs e)
{
IDataObject doa = Clipboard.GetDataObject();
MessageBox.Show(doa.GetData(DataFormats.Text).ToString());
}
上面的是用DataObject方式
如果是能直接ctrl+v粘贴的
那肯定就是Clipboard.SetText("aaa");
然后用Clipboard.GetText();来获取
private void Form1_Load(object sender, EventArgs e)
{
Clipboard.SetText("aaab");
}
private void button1_Click(object sender, EventArgs e)
{
string doa = Clipboard.GetText();
MessageBox.Show(doa);
}