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
230
Outofmemory - using images in Initialize row event
posted

I had the following code in the initialize row event of the ultragrid

 if (e.Row.Cells.Exists("UpdateMap"))
                {
                    e.Row.Cells["UpdateMap"].Value =  .......Resources.search;
                }

This would add a search image to UpdateMap column of each row in grid. [search is a png file added to the resources folder of the project.] Now when I bind the grid with a large datatable , the program exits with outofmemory exception.I presume this could be because a new image object is created for each row, thereby creating many instances of the same image.

A similar issue was reported earlier where Mike had proposed to create a set of Appearance objects to do this efficiently.

After going through the guide ,I modified the above code and have it in two events now with the appearance object

In InitializeLayout

if (!e.Layout.Appearances.Exists("SearchImage"))
            {
                Infragistics.Win.Appearance searchImage = e.Layout.Appearances.Add("SearchImage");
                searchImage.Image = .......Resources.search;
            }

 

And in InitializeRow

if (e.Row.Cells.Exists("UpdateMap"))
                {
                     e.Row.Cells["UpdateMap"].Appearance = Grid.DisplayLayout.Appearances["SearchImage"];
                }

UpdateMap column is of image type, but the grid now displays a blank cell with no image at all.What is that I am missing here?

Thanks

Rajesh