Clipboard Functionality

  • Thread starter Thread starter sonali_reddy123
  • Start date Start date
S

sonali_reddy123

Hi all

I have a problem regarding use of a clipboard functionality in .NET. As
per my knowledge we
can set the data in the clipboard of our own format. But is there any
way to clear the data after it has been set.

example


I Set the data to my format by


Data = New DataObject("MyFormat", selected)

Clipboard.SetDataObject(Data)

where selected is the array of string to set.

I use following to get the data set in my format

clipObject = Clipboard.GetDataObject()

If clipObject.GetDataPresent("MyFormat") = True Then
Dim FilesAndFolders() As String =
CType(clipObject.GetData("MyFormat"), String())

If Not FilesAndFolders Is Nothing Then
For itmCnt = 0 To FilesAndFolders.Length - 1
Debug.WriteLine(FilesAndFolders(itmCnt))
Next
End If

End If

I can get its proper

But the problem is with clearing the data set I use

clipObject = Clipboard.GetDataObject()

If clipObject.GetDataPresent("MyFormat") = True Then
Dim FilesAndFolders() As String =
CType(clipObject.GetData("MyFormat"), String())

If Not FilesAndFolders Is Nothing Then
For itmCnt = 0 To FilesAndFolders.Length - 1
clipObject.SetData("MyFormat", "")
Next
End If

End If

Is not working what could be reason is there any other efficient method
in .NET
Plz do help me thankls in advance
 
I would guess that the IDataObject objatined from Clipboard.GetDataObject()
is just a copy.
If you want to "clean" the clipboard a mor efficient way would be
Clipboard.SetDataObject(null);
 
Back
Top