0

I want to export a XtraGrid as an image. Pratically i need something like XtraChart.ExportToImage() but for the XtraGrid. Is there a method to do this?

Thanks.

smn.tino
  • 2,272
  • 4
  • 32
  • 41
  • Don't know if this helps you: http://devexpress.com/Support/Center/p/Q107282.aspx – Yuki Kutsuya Mar 23 '12 at 09:39
  • Thanks for help, but i need to export the xtragrid as image not xls because i have to insert it into a pdf file (using itextsharp library). Maybe there's something more easy to do it? Thanks. – smn.tino Mar 23 '12 at 17:57

1 Answers1

3

In windows every control can be written to a bitmap using the Control.DrawToBitmap Method. Even if the control is hidden, its possible to capture it as a bitmap.

How to get a screen capture of a .Net WinForms control programmatically?

Community
  • 1
  • 1
A G
  • 21,087
  • 11
  • 87
  • 112
  • It works very well but when i use this method for the DevExpress.XtraEditors.PanelControl, in the generated image the panel return to its default color (grey), but in the code i've change it to white. I think there's something wrong during conversion because on debugging i've verified the changing of the property "BackColor" of my panel: the change happens and the backcolor is white until the conversion, but in the image the panel is grey. What could be the problem? Thanks. – smn.tino Apr 02 '12 at 17:23
  • hmm, no idea, I have tried this on pretty complex user controls never had this problem. You can actually see the panel as white in UI? – A G Apr 03 '12 at 06:34
  • I use the panel to group some elements (text, images), then i can save it (the panel) as a bitmap with Control.DrawToBitmap method. So, my panel is instantiated dinamically and i can't see it by designer. The strange thing is that the backcolor is white before and after the call "myPanel.DrawToBitmap". Now, to resolve, i've insert a PictureBox Control (in background with the size of the panel) with white backcolor and it works. Very strange problem. – smn.tino Apr 03 '12 at 07:07