We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Unable to get GridControl.DrawGrid to produce bitmap

Hello, I am trying to create a bitmap using GridControl.DrawGrid. ontraTable.LoadTableForDisplaying collects data from Access database and translate the data into GridControl. I am able to see the GridControl on a Windows form with proper coloring. The second part of the program needs to produces a bitmap that will be painted on Graphics object. I tried to save the bitmap ''_bitmap.Save("C:\tmp.jpg", ImageFormat.Jpeg );'' I got the following: An unhandled exception of type ''System.Runtime.InteropServices.ExternalException'' occurred in system.drawing.dll Additional information: A generic error occurred in GDI+. ---Code--- GridControl OntraTableGrid = new GridControl(); ActorTable ontraTable = new ActorTable(); ontraTable.LoadTableForDisplaying( asset.Name , OntraTableGrid, asset.FileName ); using ( Bitmap gridBM = new Bitmap(asset.Bounds.Width, asset.Bounds.Height) ) { using ( Graphics g = Graphics.FromImage(gridBM)) { OntraTableGrid.DrawGrid( g ); return new Bitmap(asset.Bounds.Width,asset.Bounds.Height,g); } }

1 Reply

AD Administrator Syncfusion Team August 8, 2005 05:30 PM

Can you display the bitmap in a PictureBox (just not able to save it)? Just something to try. Before saving the bitmap, try calling bitmap1.MakeTransparent and explicitly set some tranparent color. This sample shows how you can create a bitmap using DrawGrid. The code looks similar to what you are doing. \Syncfusion\Essential Studio\3.2.1.0\Windows\Grid.Windows\Samples\In Depth\PrintToFit

Loader.
Live Chat Icon For mobile
Up arrow icon