Hi,
I try to preview a UltraWinGrid that contains 2 columns and 42 rows. One colum has type string and the other one bitmap. The second column is filled with images with size 21900x20 for each row.
I'm using the following code:
private
fullBmp;
;
e)
{
.OK)
fileName = openFileDialog1.FileName;
fullBmp = (
.FromFile(fileName);
();
table.Columns.Add(
)));
i = 0; i < 42; i++)
row = table.NewRow();
(i == 0)
row[
}
else
+ i.ToString();
.Format16bppRgb565);
] = b;
table.Rows.Add(row);
mPrintGrid =
mPrintGrid.InitializeLayout +=
(mPrintGrid_InitializeLayout);
mPrintGrid.InitializeRow +=
(mPrintGrid_InitializeRow);
//mPrintGrid.DisplayLayout.Override.DefaultRowHeight = mRowHeight;
mPrintGrid.DisplayLayout.Override.CellSpacing = 0;
mPrintGrid.DisplayLayout.Override.CellPadding = 0;
mPrintGrid.Parent =
mPrintGrid.DataSource = table;
mPrintGrid.Dock =
.Fill;
gridPanel.Controls.Add(mPrintGrid);
mPrintGrid.PrintPreview();
//mPrintGrid.Print();
e.Layout.Bands[0].ColHeadersVisible =
e.Layout.Bands[0].Override.RowSizing =
.Free;
e.Layout.Bands[0].Override.RowSpacingAfter = 0;
e.Layout.Bands[0].Override.RowSpacingBefore = 0;
e.Layout.Bands[0].Columns[
].Width = 21900;
//e.Layout.Bands[0].Columns["Image"].MergedCellStyle = MergedCellStyle.Always;
//e.Layout.Bands[0].Columns["Image"].MergedCellEvaluationType = MergedCellEvaluationType.MergeSameValue;
////e.Layout.Bands[0].Columns["Image"].MergedCellEvaluator = new ImageMergedCellEvaluator();
(e.Row.Index == 0)
e.Row.Height = 40;
e.Row.Height = 20;
The exception occurs while the preview pages are generating:
************** Exception Text **************System.Runtime.InteropServices.ExternalException: A generic error occurred in GDI+. at System.Drawing.Graphics.CheckErrorStatus(Int32 status) at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttrs, DrawImageAbort callback, IntPtr callbackData) at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr, DrawImageAbort callback) at System.Drawing.Graphics.DrawImage(Image image, Rectangle destRect, Int32 srcX, Int32 srcY, Int32 srcWidth, Int32 srcHeight, GraphicsUnit srcUnit, ImageAttributes imageAttr) at Infragistics.Win.DrawUtility.DrawImage(Graphics g, Image image, Rectangle destRect, Rectangle srcRect, Int16 alphaLevel, ImageAttributes imgAttributes, Boolean tile, ColorRenderMode colorRenderMode, ImageBackgroundStretchMargins margins) at Infragistics.Win.DrawUtility.DrawImage(Graphics g, Image image, Int16 alphaLevel, Rectangle destRect, Rectangle srcRect, Rectangle invalidRect, ImageAttributes imgAttributes, Boolean tile, ColorRenderMode colorRenderMode) at Infragistics.Win.DrawUtility.DrawImage(Graphics g, Image image, AppearanceData& appearanceData, AlphaBlendMode alphaMode, Boolean scaled, Rectangle renderRect, Rectangle invalidRect, ImageAttributes imgAttributes, Boolean maintainAspectRatio, Boolean drawBorderShadow, Color shadowColor, Byte startAlpha, Byte endAlpha, Byte shadowDepth, ColorRenderMode colorRenderMode) at Infragistics.Win.UIElementDrawParams.DrawImage(Image image, Rectangle rect, Boolean scaled, ImageAttributes imgAttributes, Boolean maintainAspectRatio, Boolean drawBorderShadow, Color shadowColor, Byte startAlpha, Byte endAlpha, Byte shadowDepth) at Infragistics.Win.ImageUIElementBase.DrawImage(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawChildElements(UIElementDrawParams& drawParams) at Infragistics.Win.UIElement.DrawElement(UIElementDrawParams& defaultDrawParams) at Infragistics.Win.UIElement.DrawHelper(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean clipText, Boolean forceDrawAsFocused) at Infragistics.Win.UIElement.Print(Graphics graphics, Boolean clipText) at Infragistics.Win.UltraWinGrid.PrintManager.PrintPage(Object sender, PrintPageEventArgs ev) at System.Drawing.Printing.PrintDocument.OnPrintPage(PrintPageEventArgs e) at System.Drawing.Printing.PrintDocument._OnPrintPage(PrintPageEventArgs e) at System.Drawing.Printing.PrintController.PrintLoop(PrintDocument document) at System.Drawing.Printing.PrintController.Print(PrintDocument document) at System.Drawing.Printing.PrintDocument.Print() at System.Windows.Forms.PrintPreviewControl.ComputePreview() at System.Windows.Forms.PrintPreviewControl.CalculatePageInfo() at System.Windows.Forms.Control.InvokeMarshaledCallbackDo(ThreadMethodEntry tme) at System.Windows.Forms.Control.InvokeMarshaledCallbackHelper(Object obj) at System.Threading.ExecutionContext.runTryCode(Object userData) at System.Runtime.CompilerServices.RuntimeHelpers.ExecuteCodeWithGuaranteedCleanup(TryCode code, CleanupCode backoutCode, Object userData) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Windows.Forms.Control.InvokeMarshaledCallback(ThreadMethodEntry tme) at System.Windows.Forms.Control.InvokeMarshaledCallbacks()
The error message you are getting here seems to indicate that the GDI+ drawing code is blowing up when trying to draw such a large image. I doubt this has anything to do with the grid, it's just that your image is too large for Windows to deal with.
Why would you want to use an image that is 20 times the width of the average screen?
The image is the result of the drawn planning control. The width depends the zoom applyed the user. There is no way to get that planning but as a drawing output.
Now, I have to print this image along with some additional data that is already bound in a UltraGrid.