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
95
Possible Grid OnPaint bug when using ControlContainerEditor
posted

Hi,

I think this maybe a bug but I'm hoping there is a way around it.

I have two monitors 1 (left) and 2 (right) and a grid with a cell containing a ControlContainerEditor.

I have a scenario where the grids location x,y is on screen 1. If the cell containing the ControlContainerEditor is expanded (either by resizing the column directly or by resizing the form with a fill docked grid and AutoFitStyle.ExtendLastColumn) and this expansion results in the new position of the right edge of that column falling on to screen 2 the following exception occurs.

System.ArgumentException: Parameter is not valid.
   at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format)
   at System.Windows.Forms.Control.DrawToBitmap(Bitmap bitmap, Rectangle targetBounds)
   at Infragistics.Win.ControlContainerEditor.GetRendererImage(Size imageSize, EmbeddableEditorOwnerBase owner, Object ownerContext, ControlContainerEmbeddableUIElement controlContainerEmbeddableUIElement)
   at Infragistics.Win.UltraWinEditors.ControlContainerEditorEditAreaUIElement.DrawForeground(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, Boolean preventAlphaBlendGraphics)
   at Infragistics.Win.UIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Boolean forceDrawAsFocused, Boolean preventAlphaBlendGraphics)
   at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize, Boolean preventAlphaBlendGraphics)
   at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode, Size elementSize)
   at Infragistics.Win.ControlUIElementBase.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode)
   at Infragistics.Win.UltraWinGrid.UltraGridUIElement.Draw(Graphics graphics, Rectangle invalidRectangle, Boolean doubleBuffer, AlphaBlendMode alphaBlendMode)
   at Infragistics.Win.UltraControlBase.OnPaint(PaintEventArgs pe)
   at Infragistics.Win.UltraWinGrid.UltraGrid.OnPaint(PaintEventArgs pe)
   at System.Windows.Forms.Control.PaintWithErrorHandling(PaintEventArgs e, Int16 layer, Boolean disposeEventArgs)
   at System.Windows.Forms.Control.WmPaint(Message& m)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

The problem also occurs in the ControlContainerEditor example project, I used the "Same Control" example. I did notice that this configuration wont let you resize the column outside the bounds of screen 1 but if you make it big enough first and then move the whole form so that ity is cross screens and try to resize it again you get the same exception.

Any ideas?

 

Thanks,

Andy.

 

Parents
  • 469350
    Suggested Answer
    Offline posted

    Hi Andy,

    I tried this out with the sample and I do indeed get the problem you are describing. But the exception is not coming from Infragistics code, it's coming from a DotNet Framework method. It's blowing up in DrawToBitmap, which is a method on Control. It looks like this method blows up if you try to draw a control bigger than the current screen.

    There's probably not much we can do about this, other than report the issue to Microsoft as a bug in DotNet. But it's something we should probably look into. Perhaps we can get around it in full-trust environments using Windows API's to draw the control ourselves when necessary.

    So I'm going to forward this thread over to Infragistics Developer Support so they can write it up and get it looked at.

Reply Children