My class: Checks, Cannot check to see if object in clipboard.

aewarnick

Senior Contributor
Joined
Jan 29, 2003
Messages
1,031
I have tried many things to do a simple check to return either true or false, for object in clipboard. Nothing has worked so far. Here is my last resort and the code that I think is close but does not work right:
Code:
public static bool ClipBOccupied()
	{
		if(Clipboard.GetDataObject().Equals(null))
			return true;
				return false;
	}
It seems to me that the clipboard always has something in it, because when I copy bland rtb text it returns false. It always returns false. Please help.
 
Last edited:
Have you tried using Clipboard.GetDataObject().GetDataPresent()? I think that's probably what you're looking for.
 
You are absolutely right divil:

Code:
public static bool ClipB_String_Image()
			{
				try
				{
					if(Clipboard.GetDataObject().GetDataPresent(typeof(String)))
					{
						if(Clipboard.GetDataObject().GetData(typeof(String)).Equals(""))
							return false;
						return true;
					}

					if(Clipboard.GetDataObject().GetDataPresent(typeof(Bitmap)))
						return true;
					return false;
				}
				catch{MessageBox.Show("a.Checks.ClipB_Any()", "Error"); return false;}
			}
 
Back
Top