aewarnick Posted March 19, 2003 Posted March 19, 2003 (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 March 19, 2003 by aewarnick Quote C#
*Gurus* divil Posted March 20, 2003 *Gurus* Posted March 20, 2003 Have you tried using Clipboard.GetDataObject().GetDataPresent()? I think that's probably what you're looking for. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
aewarnick Posted March 20, 2003 Author Posted March 20, 2003 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;} } Quote C#
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.