■ クリップボードから取得
* クリップボードへのデータ転送とデータ取得は、Clipboardクラスのstaticメソッドを使用する * 以下の関連記事を参照。https://blogs.yahoo.co.jp/dk521123/29251855.html
サンプル
textBox1.Text = Clipboard.GetText();
■ クリップボードに矩形選択されたイメージをコピーする
.NET2.0以降* Clipboard.SetImage() を使う.NET1.1以前
* Clipboard.GetDataObject() を使う
サンプル
以下の関連記事より抜粋https://blogs.yahoo.co.jp/dk521123/37857445.html
Bitmap image = new Bitmap(this.pictureBox1.Image); Bitmap selectedImage = image.Clone(this.targetRectangle, image.PixelFormat); Clipboard.SetImage(selectedImage);
参考文献
http://d.hatena.ne.jp/gya-ia/20151201/1448902907http://www.atmarkit.co.jp/fdotnet/dotnettips/912bitmapcroprect/bitmapcroprect.html
https://dobon.net/vb/dotnet/graphics/getclipboarddata.html
■ クリップボードにコピーされたイメージをpictureBoxに貼り付ける
サンプル
private void button1_Click(object sender, EventArgs e) { var bitmap = Clipboard.GetImage(); if (bitmap != null) { pictureBox1.Image = bitmap; } }
■ コピー後、ラベルに完了の旨を表示し、メッセージをクリアする
* Timerを利用する
サンプル
using System; using System.Drawing; using System.Windows.Forms; namespace SampleForm { public partial class Form1 : Form { private Timer timer; public Form4() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { Clipboard.SetText(this.label1.Text + ", " + this.label2.Text); this.timer.Start(); this.label3.Text = "保存しました"; } private void ClearLabel(object sender, EventArgs e) { this.label3.Text = String.Empty; this.timer.Stop(); } } }
参考文献
https://detail.chiebukuro.yahoo.co.jp/qa/question_detail/q1371501448関連記事
ContextMenuStrip ~右クリックを使うには~
https://blogs.yahoo.co.jp/dk521123/22454285.htmlクリップボード ~コピー&ペーストを実装する~
https://blogs.yahoo.co.jp/dk521123/29251855.htmlPictureBox [7] ~ 画像をコピーする・その1 ~
https://blogs.yahoo.co.jp/dk521123/37857445.html