| VB.NET | |
|
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 021 022 023 |
' クリップボードにデータをコピーする Private Sub buttonCopy_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonCopy.Click ' テキストボックスの文字列をコピーする Clipboard.SetDataObject(textBoxSource.Text) End Sub ' クリップボードからデータを貼り付ける Private Sub buttonPaste_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles buttonPaste.Click ' クリップボードのデータを取得する Dim dataObject As IDataObject = Clipboard.GetDataObject() ' テキスト形式のデータかどうか確認する If dataObject.GetDataPresent(DataFormats.Text) Then ' テキスト形式のデータを取得し、テキストボックスに貼り付ける textBoxDest.Text = CType(dataObject.GetData(DataFormats.Text), String) End If End Sub |
| C# | |
|
001 002 003 004 005 006 007 008 009 010 011 012 013 014 015 016 017 018 019 020 |
// クリップボードにデータをコピーする private void buttonCopy_Click( System.Object sender, System.EventArgs e ) { // テキストボックスの文字列をコピーする Clipboard.SetDataObject( textBoxSource.Text ); } // クリップボードからデータを貼り付ける private void buttonPaste_Click( System.Object sender, System.EventArgs e ) { // クリップボードのデータを取得する IDataObject dataObject = Clipboard.GetDataObject(); // テキスト形式のデータかどうか確認する if ( dataObject.GetDataPresent( DataFormats.Text ) ) { // テキスト形式のデータを取得し、テキストボックスに貼り付ける textBoxDest.Text = (string)dataObject.GetData( DataFormats.Text ); } } |