Jump to content
Software FX Community

Export to Clipboard


Recommended Posts

Hey All, I am using theis piece of code to export chart to clipboard, but it is throwing exception when I try to paste it later into paint for instance...

// create a memory stream to save the chart image var stream = new MemoryStream();

// save the chart image to the stream chart1.Export(FileFormat.Bitmap, stream);

// create a bitmap using the stream var bmp = new Bitmap(stream);

// save the bitmap to the clipboard


 I get COMexception: Invalid FORMATETC structure (Exception from HRESULT: 0x80040064 (DV_E_FORMATETC)). Any ideas?

Link to comment
Share on other sites

I copied your code and it worked fine on 2 different machines. You might want to try changing your SetDataObject to this to see if it makes any difference

Clipboard.SetDataObject(new DataObject(DataFormats.Bitmap, bmp), true);

Also you can try exporting as a png instead of bitmap, both changes also worked in our tests. 



Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

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...