Posted on 2004-08-09
Last Modified: 2010-04-17
how to write cut copy paste code in
Question by:imrancs
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

SNilsson earned 500 total points
ID: 11760040

Expert Comment

ID: 11760468
  This is from MSDN:
  A number of applications use the Clipboard as a temporary repository for data. For example, word processors use it during cut/copy/paste operations. Accessing the Clipboard and storing data there with a Windows application is made possible through the use of the SetDataObject method, which stores the data on the Clipboard using the IDataObject interface. The SetDataObject method does this so that, when the data is later retrieved from the Clipboard, it can be done so in a variety of formats.
  To set data to clipboard:
  Clipboard.SetDataObject(TextBox1.Text) (VB.NET)
  To paste data:
  'Create a new instance of the DataObject interface.
  Dim data As IDataObject = Clipboard.GetDataObject()
  'If the data is text, then set the text of the
  'TextBox to the text in the Clipboard.
  If (data.GetDataPresent(DataFormats.Text)) Then
    TextBox1.Text = data.GetData(DataFormats.Text).ToString()
  End If


Expert Comment

ID: 11767439
Private Sub cmdLoadImage_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdLoadImage.Click
'loading image into the picture box
End Sub

Private Sub cmdCopyImage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdCopyImage.Click
'copying image to clipboard from picturebox
End Sub

Private Sub cmdPasteImage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdPasteImage.Click
'pasting copied image back to the picturebox
End Sub

Private Sub cmdClearImage_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles cmdClearImage.Click
'clear picturebox image
End Sub

Public Sub ClearImage()
'clear image from picturebox
End Sub

Public Sub PasteImage()
'check the data format in clipboard if its of type bitmap then proceed further
If Clipboard.GetDataObject.GetDataPresent(DataFormats.Bitmap) Then
'setting clipboard data to picturebox
PictureBox1.Image = Clipboard.GetDataObject.GetData(DataFormats.Bitmap)
End If
End Sub
Public Sub CopyImage()
'copy image to clipboard
'setting picturebox data to clipboard
End Sub

Public Sub LoadImage()
'shows OPEN FILE DIALOG for locating graphic files on the harddisk
'setting visible file filter
OFD.Filter = "Images | *.bmp;*.tif;*.jpg;*.gif"
'Show OPEN FILE DIALOG to user
'Load located file to the picturebox
PictureBox1.Image = Image.FromFile(OFD.FileName)
End Sub
Private Sub Form1_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown

'Short cut keys implementation
If e.Control And e.KeyCode = Keys.C Then
End If
If e.Control And e.KeyCode = Keys.L Then
End If
If e.Control And e.KeyCode = Keys.V Then
End If
If e.Control And e.KeyCode = Keys.R Then
End If

End Sub

Featured Post

Get 15 Days FREE Full-Featured Trial

Benefit from a mission critical IT monitoring with Monitis Premium or get it FREE for your entry level monitoring needs.
-Over 200,000 users
-More than 300,000 websites monitored
-Used in 197 countries
-Recommended by 98% of users

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…
Starting up a Project

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question