Re: Can’t copy to clipboard

From: Jeff Gaines (jeff_at_jgaines.co.uk)
Date: 02/20/04


Date: Fri, 20 Feb 2004 10:02:11 +0000

On Thu, 19 Feb 2004 07:56:05 -0800, Dennis
<anonymous@discussions.microsoft.com> wrote:

>I get the following exception when I try to put a string in the clipboard:
>
>Unhandled Exception: System.Runtime.InteropServices.ExternalException: The requested clipboard operation failed.
> at System.Windows.Forms.Clipboard.SetDataObject(Object data, Boolean copy)
>
>Could anyone tell me what’s wrong with this program? Thanks
>
>using System.Windows.Forms;
>
>public class Test
>{
> public static void Main()
> {
> Clipboard.SetDataObject("test", true);
> }
>}

Dennis

This works for me:

private void btnCopyAddress_Click(object sender, System.EventArgs e)
                {
                        string strAddress = txtName.Text + '\n' + rtfAddress.Text;
                        Clipboard.SetDataObject(strAddress);
                }

But it's really no different to what you are doing.

Is your program capturing the Clipboard elsewhere and not releasing
it?

-- 
Jeff Gaines Damerham Hampshire UK


Relevant Pages

  • Re: changing methods access modifires in runtime?
    ... public Class Test { ... Test (boolean isPublic,...){ ... //changing someMethod() to public ... private void someMethod{ ...
    (comp.lang.java.programmer)
  • Re: Try...Catch across assemblies
    ... you will get a messagebox showing the error when run from ... The bad news is I don't entirely understand it. ... public class Test: Form ... private void LoadEventHandler ...
    (microsoft.public.dotnet.framework)
  • Re: Writing arraylist items to the page
    ... Dennis JD Myrén ... >>> private void ArrayList_Click(object sender, ...
    (microsoft.public.dotnet.general)
  • Unhandled Exceptions outside of VS
    ... Some of us on the .net framework were working on an issue that I've ... generate an unhandled exception. ... public class Test: Form ... private void LoadEventHandler ...
    (microsoft.public.dotnet.framework.windowsforms)
  • RE: Timer and Monitor
    ... > Instead of Monitor class you can lock the block by a boolean variable.... ... > private void timer_tick ...
    (microsoft.public.dotnet.framework.windowsforms)