Jump to content
Software FX Community

Export to Clipboard


Bober02
 Share

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

Clipboard.SetDataObject(bmp);

 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. 

JuanC

post-7688-13922416336076_thumb.png

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.

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.

 Share

×
×
  • Create New...