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
170
Best way to initialize Rows
posted

Hi,

in my wingrid i need to display the value of certain column with images, based on the value of the cell.

I use the InitializeRow events and Row by Row i change the value of Appearance.Image because i have an imageList linked to the wingrid.

The question is : when i have 20000 - 50000 records looping over all of this, i have low-performance. Is there a more efficient solution?

I think about the InitializeRowCollection but can I manage the value row by row ?

 

Parents
  • 469350
    Verified Answer
    Offline posted

    Hi,

        What exactly do you mean when you say you are looping through the rows? If you are using the InitializeRow event, you should not have to do any loops, the event fires for each row.

        How many images do you have? My guess is that you might be doing this inefficiently by setting the row.Cells[x].Appearance.Image on the cell directly. This means you are creating a new appearance object for every cell. It's much more efficient to create a set of Appearances (in the grid.DisplayLayout.Appearances) collection - one for each image, and then apply the entire appearance to the cell. This limits the number of appearance objects you create.

        If that still doesn't help, you might want to consider using a DrawFilter instead of the InitializeRow event. In this approach, what you do is assign a single image to the entire column - probably just a blank image to create a space. Then youuse the DrawFilter to override the drawing of the ImageUIElement inside the cell. This way you only draw the images for cells that are actually on the screen, so it's much more efficient.

         

Reply Children