剪贴板
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace Clipboard_Test
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
if (string.IsNullOrEmpty(richTextBox1.Text.Trim()) || string.IsNullOrEmpty(richTextBox1.SelectedText.Trim()))
{
return;
}
Clipboard.SetDataObject(richTextBox1.SelectedText.Trim(), true);
}
private void button2_Click(object sender, EventArgs e)
{
IDataObject ido = Clipboard.GetDataObject();
richTextBox1.Text += (string)ido.GetData(DataFormats.Text);
}
}
}