Hello,
I noticed something peculiar using an Ultragrid, UltraDatasource, LoadStyle.LoadOnDemand, BeginUpdate() and EndUpdate(). Under Windows 7 x86, 64, Windows 8 and Windows XP (configured with a Windows XP theme) all works smoothly.
However, under Windows 2008 (non aero theme) or Windows XP with a Classic Theme, the background flashes to black for a second using BeginUpdate() and EndUpdate(). When I leave using the two methods out of my code, the background doesn't flash and forth to black and then white. I've tested with Infragistics 2011.2 and 2012.1, both have the same behavior.
What could be the issue here?
regards,
Roel van Bueren
Hello Roel,
I wanted to know if you were able to solve your issue based on these suggestions or you still need help. Please let me know.
Hi,
I would very strongly advise you against attempting to use a separate thread anywhere near the WinGrid or any bound control. It order to use threads, you have to marshal all communication between those threads and in the case of DataBinding, you are not in control of the communication between the grid, the BindingManager, and the DataSource, so it's not possible to do proper marshaling.
Having said that, I'm not sure exactly what the situation is here. Are you saying that you are already using LoadOnDemand? Or are you considering that as a possible solution to the image problem?
If you are already using LoadOnDemand, then only the rows in the grid that are in view will be loaded and InitializeRow will only fire for those rows, so it seems very unlikely that you would have a performance problem in that case.
There are a number of ways you could speed things up, but without knowing more about exactly what you are doing now and what's causing the slowdown, it's hard to give you any more specific advice.
Are you using LoadOnDemand now?
How many images do you have? Typically, an application will not have a different image for every cell. You probably have a small set of images and you apply the same image to many cells. If that's the case, you might want to take a look at the WinGrid Performance Guide. There's a section on re-using appearances that may help.
It might also be a good idea for you to load your image from the file only once and then keep it in memory so you can re-use it, rather than loading it from a file every time you need it.
One additional question here. In the same situation I'm using the InitializeRow event of the grid in order to set the row appearance, which basically only contains an image here. Since the image is a file icon, which has to be extracted from the file first, this process is relatively slow and therefore slows down the total performance of loading the grid with new data.
What's the best way, using LoadStyle.LoadOnDemand. Do I have to run this in a separate thread e.g.?
Thank you Mike! Spot on ... one grid refresh was between BeginUpdate() and EndUpdate() and has been moved to run after the EndUpdate().
Many thanks!
Roel
Hi Roel,
When you call BeginUpdate on the grid, this tells the grid not to paint itself. If something invalidates the grid and forces the grid to repaint - like if you called the Refresh method, for example, then the grid would be painted and simply skip it's own internal painting logic and it would end up painting in solid block.
So my guess is that something in Windows XP is forcibly invalidating and re-painting the grid while you are inside your BeginUpdate/EndUpdate block. There are some known differences in the way Windows XP handles painting under certain conditions. For example, when you resize a form, some O/S's will force the controls on that form to paint and others will not.
Tracking this down will be probably be pretty difficult. It depends what exactly is happening in between the BeginUpdate and EndUpdate statements.
If you want to try to track it down, then there are a couple of approaches you could try.
1) Immediately before, or perhaps after, you call BeginUpdate, hook the Paint event of the grid and put a breakpoint in the event. See if it gets hit and if it does, you can look at the call stack and that might give you a clue as to what's forcing the grid to paint.
2) Take a look at the code you are using in between BeginUpdate and EndUpdate and try commenting out parts of it to see if you can narrow down the code that is causing the flicker. The flickering may not be caused directly by this code, of course. This code could be triggering an event and that event handler code could be the cause. So you may also want to try commenting out any event handler code for your grid (and possibly other controls on the form) to see if you can narrow it down that way.