using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Linq; using System.Text; using System.Windows.Forms; namespace Clipboard1 { public partial class Form1 : Form { public Form1() { InitializeComponent(); } //copy Text private void button1_Click(object sender, EventArgs e) { Clipboard.SetDataObject(richTextBox1.SelectedText); } //Paste Text private void button2_Click(object sender, EventArgs e) { richTextBox1.Text= Clipboard.GetText().ToString(); //if (Clipboard.GetDataObject().GetDataPresent(DataFormats.Text)) // textBox1.Text = Clipboard.GetDataObject().GetData(DataFormats.Text).ToString(); //else // textBox1.Text = "The clipboad does not contain any text"; //////label1.Text = Clipboard.GetText(); //// Retrieves data //IDataObject iData = Clipboard.GetDataObject(); //// Is Data Text? //if (iData.GetDataPresent(DataFormats.Text)) // label1.Text = (String)iData.GetData(DataFormats.Text); //else // label1.Text = "Data not found."; } //clearing ClipBoard private void button3_Click(object sender, EventArgs e) { Clipboard.Clear(); } //Copy Image private void button4_Click(object sender, EventArgs e) { if (opnImage.ShowDialog() == DialogResult.OK) { Image imgToCopy = Image.FromFile(opnImage.FileName); Clipboard.SetImage(imgToCopy); } } //Paste Image private void button5_Click(object sender, EventArgs e) { picClipboard.Image = Clipboard.GetImage(); } } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)