I'm using Clipboard events to copy data from clipboard to my application which includes a Microsoft Word.
it will paste data to the word as soon as the user hits copy anywhere in windows. But I don't want to paste the same data if the user hits Ctrl + C twice.
Now as this answer suggests, I can't use IsCurrent
to compare DataObjects
So I'm doing it this way:
if (Clipboard.GetData(DataFormats.UnicodeText).ToString()!=oldData)
{
//Paste and stuffs
oldData= Clipboard.GetData(DataFormats.UnicodeText).ToString();
}
But it only works if the data contains some texts and I'm getting null reference error if it doesn't.
So is there any way to know if the DataObject
contains anthing else than text (say Bitmap
) and be able to compare them?