Hi. I'm using the WinGrid version 10.2 and have a question about column resizing.
When I load a grid with data, and call:
column.PerformAutoResize(PerformAutoSizeType.VisibleRows);
The columns are sized based on the column header data, not the data in the rows. The columns must resized manually. If I used the AllRows option, the columns resize.
Is there a "trick" to using the .VisibleRows option? Should it only be used during certain grid events?
Hi,
VisibleRows sizes only based on the rows that have been currently loaded and are visible in the grid. This will not work if you call this method before the first time the grid paints, because the grid doesn't create any row objects until it needs to draw them on the screen. So it's generally that useful to call it in code, it's mostly there for the RowAutoSizeMode property so that when the user double-clicks to autosize a row it doesn't force all of the data to load or cause any performance problems.
The AllRowsInBand option, on the other hand, forces the creation of all of the rows regardless of their visibility.
In my experience, unless you are loading your grid data on demand, you are almost always better off using AllRowsInBand, since it's so fast, anyway.
Let me know if you need any additional help.
Regards,
Stefaniya
If you need more help, I will open a support ticket for you or you can post your questions here.
No, there's no event for this. What you could do is set the DataSource on the grid and then call the Update method, or maybe Refresh. I'd try Update first and see if that works. Either way, calling Update or Refresh will force the grid to paint and thus create at least enough rows to fill the visible area of the grid. Then you can call PerformAutoResize and specify only the visible rows.
Stefania,
Hi. Yes, I do need more help. I'm currently using the ResizeAllRows option in my application after the data is loaded. That works for small patient cases. However, when the application has collected thousands of rows of data, re-loading the case becomes much slower. Is there a grid event that I can use as a notification that the visible grid rows have been created and then resize based on the visible rows only?
Thank you.