Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
115
UltraWinGrid PrintPreview exception
posted

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

 

 

Bitmap

fullBmp;

 

 

private UltraGrid mPrintGrid = null

;

 

 

private void button3_Click(object sender, EventArgs

e)

{

 

 

if (openFileDialog1.ShowDialog() == DialogResult

.OK)

{

 

 

string

fileName = openFileDialog1.FileName;

{

fullBmp = (

 

Bitmap)Bitmap

.FromFile(fileName);

 

 

 

DataTable table = new DataTable

();

table.Columns.Add(

 

new DataColumn("Name", typeof(String

)));

table.Columns.Add(

 

new DataColumn("Image", typeof(Bitmap

)));

 

 

for (int

i = 0; i < 42; i++)

{

 

 

DataRow

row = table.NewRow();

 

 

if

(i == 0)

{

row[

 

"Name"] = "_Header_Name"

;

}

 

 

else

{

row[

 

"Name"] = "Name"

+ i.ToString();

}

 

 

Bitmap b = fullBmp.Clone(new Rectangle(0, i*20, 21900, 19), System.Drawing.Imaging.PixelFormat

.Format16bppRgb565);

row[

 

"Image"

] = b;

table.Rows.Add(row);

}

 

mPrintGrid =

 

new UltraGrid

();

mPrintGrid.InitializeLayout +=

 

new Infragistics.Win.UltraWinGrid.InitializeLayoutEventHandler

(mPrintGrid_InitializeLayout);

mPrintGrid.InitializeRow +=

 

new Infragistics.Win.UltraWinGrid.InitializeRowEventHandler

(mPrintGrid_InitializeRow);

 

 

//mPrintGrid.DisplayLayout.Override.DefaultRowHeight = mRowHeight;

mPrintGrid.DisplayLayout.Override.CellSpacing = 0;

mPrintGrid.DisplayLayout.Override.CellPadding = 0;

 

mPrintGrid.Parent =

 

new Form

();

mPrintGrid.DataSource = table;

mPrintGrid.Dock =

 

DockStyle

.Fill;

gridPanel.Controls.Add(mPrintGrid);

 

mPrintGrid.PrintPreview();

 

 

//mPrintGrid.Print();

}

}

 

}

 

 

void mPrintGrid_InitializeLayout(object sender, Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs

e)

{

e.Layout.Bands[0].ColHeadersVisible =

 

false

;

e.Layout.Bands[0].Override.RowSizing =

 

RowSizing

.Free;

e.Layout.Bands[0].Override.RowSpacingAfter = 0;

e.Layout.Bands[0].Override.RowSpacingBefore = 0;

e.Layout.Bands[0].Columns[

 

"Image"

].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();

}

 

 

void mPrintGrid_InitializeRow(object sender, Infragistics.Win.UltraWinGrid.InitializeRowEventArgs

e)

{

 

 

if

(e.Row.Index == 0)

{

e.Row.Height = 40;

}

 

 

else

{

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()