Jump to content
Xtreme .Net Talk

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


Recommended Posts

Posted (edited)

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:

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.

Edited by aewarnick
C#
Posted

You are absolutely right divil:

 

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;}
		}

C#

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...