Hi
Experiencing very slow Excel access when using CustomDrawCellBackground.
I have a grid which list reports available in my application for the user to select and run.
There are 76 rows with 20 columns (one image, two text and 17 check boxes).
I wrote Display, Print, CSV, PDF and Excel export routines for the reports (all working fast).
One large report exports to excel in 10 seconds.
I then added a CustomDrawCellBackground event to draw a progress bar and % text in a cell for the row of the report being exported.
Takes about 15 seconds now to export to excel.
As I did not like the standard checkboxes (mostly because of the background colour which I could not fine a way to change), I used the CustomDrawCellBackground to draw all checkboxes in the grid (nice pale green background).
The same export to excel now takes several minutes.
I noticed that every call to Excel causes the CustomDrawCellBackground event to be raised for each cell several times (I don't know why).
I use Excel.Range to apply an excel style to ranges of cells so that I can duplicate the formatting of the grid content. e.g. font, colours, number formatting etc.
I then removed the code for drawing the textboxes within CustomDrawCellBackground, and created a CustomButtonRenderer class attaching this to iGrid.CustomControlPaint. This gave the grid the same look as previously, but it still caused the export to take a long time.
The only way I can get the speed, and keep my checkboxes, is to call "SendMessage(iGrid.Handle, WM_SETREDRAW, True, IntPtr.Zero)" to suspend iGrid drawing and then again (with false) to re-enable the drawing), before and after my excel.range calls.
However, using this approach prevents my progress bar from being displayed within the grid.
Using BeginUpdate and EndUpdate does not change the speed.
Help?