Hi there,
we use an Infragistics for WinForms 2010.1.
We have an UltraGrid derived Control with 4 grouped columns. The cells of one of this columns has set Appearance.Image property to a dynamically created Bitmap. This happens within an InitializeRow handler of the grid.
The Bitmap are created like here:
private static Bitmap getAktionsArtImage(MasterData mdAktionsArt) { if (mdAktionsArt != null && mdAktionsArt.Color is Color) { var c = (Color)mdAktionsArt.Color; var img = new Bitmap(16, 16); using (Graphics g = Graphics.FromImage(img)) g.FillRectangle(new SolidBrush(c), 0, 0, 15, 15); return img; } return null; }
By this constellation we change anything on the DataSource listand get an System.ArgumentException. What can be wrong here? Is this an Infragistics, my or .NET bug?
StackTrace: bei System.Drawing.Image.get_Width() bei System.Drawing.Image.get_Size() bei Infragistics.Win.UltraWinGrid.GroupByRowDescriptionUIElement.PositionImageHelper(UltraGridGroupByRow row, Rectangle& workRect, GroupByRowDescriptionUIElement containerElem, UIElementsCollection oldElements) bei Infragistics.Win.UltraWinGrid.GroupByRowDescriptionUIElement.PositionChildElements() bei Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) bei Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) bei Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) bei Infragistics.Win.UltraWinGrid.RowColRegionIntersectionUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) bei Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) bei Infragistics.Win.UltraWinGrid.DataAreaUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) bei Infragistics.Win.UIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) bei Infragistics.Win.UltraWinGrid.UltraGridUIElement.VerifyChildElements(ControlUIElementBase controlElement, Boolean recursive) bei Infragistics.Win.UIElement.VerifyChildElements(Boolean recursive) bei Infragistics.Win.ControlUIElementBase.VerifyIfElementsChanged(Boolean verify, Boolean syncMouseEntered) bei Infragistics.Win.ControlUIElementBase.get_CurrentCursor() bei Infragistics.Win.UltraControlBase.get_Cursor() bei System.Windows.Forms.Control.WmSetCursor(Message& m) bei System.Windows.Forms.Control.WndProc(Message& m) bei System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) bei System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) bei System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
Hi Mike,
thanks to the fast answer. Seems to be true. If i comment out the disposing, i get no exceptions anymore. Too bad, i thougth ResourceManager get always a new instance by each property access, and this was a memory leak for me.
Hi,
I ran your sample and I am getting the exception when I group by the PriorityID.
I beleive the problem with your code.
The images you are using here are coming from the project resources. But your replaceImage method is disposing these resources. That does not make sense, because you are using and re-using these same two images repeatedly.
The Exception here is occurring because the grid is trying to access the Size property on one of these images and it cannot because the image has been disposed.
There is my project. Steps to reproduce:
1. Drag columns with images to the grouping area. Even one of both is enough.
2. Select a data row.
3. Click on grid's context menu "Done".
4. Get an exception
I'm not aware of any grid bugs that would cause this. At least not that I remember.
Can you reproduce this exception in a small sample project and post it here?
Without a sample, my best guess would be that your application is using multiple threads which is causing the grid to get out of synch.