Hi all,
I recently stumbled into the million rows example (virtual mode) for the WinGrid. That example works perfectly fast and reliable.
I my case I need to pull only 200.000 rows from a LinQ DataSource and display them in the WinGrid. Using the example I quickly succeeded in displaying these rows in just a few seconds.
That is where my problem enters the "game".I need conditional formatting based on the value of a hidden column (0/1) that should result in adding an icon to a cell in each row and in making the row "bold", based on the value (0 = normal + icon1 / 1 = bold + icon2).
My first guess was to add the "checking" to the InitializeRow event of the grid.The result was quite destructive to the performance.My second (more desperate guess) was to check all rows after loading and then do the formatting. That also didn't solve the problem and took far too long.
Would you mind to help me figuring out on how to archive my goal using the WinGrid?Maybe you could post the mentioned example using some conditional formatting as described?That would be great ;)Any ideas are kindly appreciated.
Thanks in advance and best regardsAndy
Hi Andy,
InitializeRow is the perfect place to do this. Only the rows that are loaded should be initialized and this fire the event. So if you are experiencing performance problems when using this event, you may be writing your code inefficiently and be forcing the rows to be loaded unnecessarily.
Can you post the code you had in InitializeRow?
Hi Mike,good hearing from you ;)
Here is the code you asked for that ran in the InitializeRowEvent:
// handling processing status in order to format the row the right wayswitch (readStatus){case 0: // unreade.Row.Appearance.FontData.Bold = Infragistics.Win.DefaultableBoolean.True;e.Row.Cells["readStatusIcon"].Value = (Bitmap) this.imgListEmailInbox.Images[1]; //removedbreak;
}
In the meantime I removed the Bitmap-Stuff that seemed to consume quite a lot of performance and it ran better. Still not sufficient enough to keep it this way, but I need an image there which I am now able to add via the CustomFormatting Tool on DesignTime.
I just started to work with the infragistics tools, so odds are pretty good that I miss something.
Thank you Mike for the time to look into this,have a great dayAndy
This code is a bit ineffcient memory-wise, because you are creating a new Appearance object for every row, when you could just as easily re-use a single Appearance object. And you are create cells unnecessarily by using the Value property on the cell.
You might want to check out the WinGrid Performance Guide for some tips to save memory.
But none of that should affect performance. I don't see anything here that would cause a performance problem. You are not doing anything that should cause any rows to be loaded that would not already have been loaded by the grid. How many times is the event firing initially? Are you saying it's firing for all the rows in the data source and not just the ones it needs?
Hi Mike,
first of all, I really appreciate your help. I will definitely check out the WInGrid PerformanceGuide before proceeding any further.
Regarding the loading of the rows. I am not quite sure if I understood the question correctly, but I have set the LoadStyle of the Grid to LoadOnDemand.The Event seems to fire for all rows (at least for a couple of hundreds, that was when I stopped debuggin it).
Let me know if you need any clarification,
have a great day,best regardsAndy
Well, if you are certain that it's the code in InitializeRow that is making the difference in performance, then I guess checking the performance guide is a good idea. But I really don't see how anything you are doing there could slow down the grid in any significant or noticeable way.
If the images are slowing it down, then you might want to use a DrawFilter or a CreationFilter to provide the images, instead of using the cell value. The advantage of the DrawFilter/CreationFilter is that you only supply the images to the cells that are actually displayed on the screen instead of all of the images in every row.
There's a discussion of this technique here: Initialize rows as they are displayed, or Win equivalent for LoadOnDemand property - Infragistics Community
Mike Saltzman said:If the images are slowing it down, then you might want to use a DrawFilter or a CreationFilter to provide the images, instead of using the cell value. The advantage of the DrawFilter/CreationFilter is that you only supply the images to the cells that are actually displayed on the screen instead of all of the images in every row.
Isn't there a way to refer to Images using ImageIndex.
BB said:Isn't there a way to refer to Images using ImageIndex.
I don't understand what you mean. What's an ImageIndex?