Last Updated: 10 Aug 2016 15:47 by Robert Gray
Dess | Tech Support Engineer, Principal
Created on: 25 Feb 2016 12:33
Category: GridView
Type: Bug Report
FIX. RadGridView - TargetInvocationException when scrolling to the bottom in a grid with GridViewImageColumn
To reproduce:

GridViewImageColumn imageColumn = new GridViewImageColumn();
imageColumn.Name = "ImageColumn";
imageColumn.FieldName = "ImageColumn";
imageColumn.HeaderText = "Picture";

List<classBinding> databinding = new List<classBinding>();
for (int i = 0; i < 35000; i++)
    databinding.Add(new classBinding()
        ImageColumn = Properties.Resources.Alarm2, 
radGridView1.DataSource = databinding;

 public class classBinding
            public System.Drawing.Bitmap ImageColumn { get; set; } 
Robert Gray
Posted on: 10 Aug 2016 15:47
I understand your recommendation.  I'll give that a try.  Thanks Dess.
Dess | Tech Support Engineer, Principal
Posted on: 04 Aug 2016 11:13
Hello Robert,
Thank you for writing.
When you bind the grid to a collection that contains an image property in its records, RadGridView creates a distinct Image for each record. Thus, the limit is reached. Hence, the error occurs. I would recommend you to use a simple GridViewTextBoxColumn and assign the desired image by using the CellFormatting event.
Robert Gray
Posted on: 03 Aug 2016 14:05
I have a similar issue (see Support ID:1054674). I agree that 35k *distinct* images would be too much, however in both my case and the one shown here, all records contain the same image. (Ok, in my case there are two possibilities, both also from resources - an OK sign and an ERROR sign.)

I have checked the Task Manager window and the number of GDI resources doesn't even get to 100, even though I have 20k+ records and I scroll to about half of them before crashing.

Is the grid view creating a distinct image for each record, instead of reusing the same image? (But still, why wouldn't I see that in the Task Manager?)
Posted on: 05 May 2016 14:26
This case is not an issue of RadGridView, it is rather system limitation. When the grid is populated with unique images, the application exceed the maximum number of allowed bitmaps (GDI objects) for a process.
We can recommend to review the design of application and avoid using so too many unique GDI resources. More information about handling of GDI issues can be found here:
* GDI Objects -
* Debugging a GDI Resource Leak -