To reproduce:
GridViewImageColumn imageColumn = new GridViewImageColumn();
imageColumn.Name = "ImageColumn";
imageColumn.FieldName = "ImageColumn";
imageColumn.HeaderText = "Picture";
radGridView1.MasterTemplate.Columns.Add(imageColumn);
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; }
}
I understand your recommendation. I'll give that a try. Thanks Dess.
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.
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?)
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 - https://msdn.microsoft.com/en-us/library/windows/desktop/ms724291%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396 * Debugging a GDI Resource Leak - https://blogs.msdn.microsoft.com/dsui_team/2013/04/23/debugging-a-gdi-resource-leak/