I have GridControl in virtual mode.
Sometimes I should changing column count. Count of displaying columns changing in Form, that appears above grid.
After I decrease column count and press OK on form, the form dissapear and grid refreshes those fields, that was below the form.
After that, QueryCellInfo request data for columns, that already not in available range of columns (decreased).
So, how can I synchronize internal switching of column count or row count with grid drawing process ?
ADAdministrator Syncfusion Team August 19, 2004 12:08 AM
Normally, in a pure virtual grid you never set grid.RowCount or grid.COlCount.
Instead, you handle QueryRowCount and QueryColCount and provide the values there by setting e.Size = ??? and e.Handled = true. The values you set come directly from your datasource. Doing it this way allows the grid to work with your data without allocating space for rows and columns. If you explicitly set grid.RowCount and Grid.ColCOunt, the grid will allocate space. Now this ok if you are aware of it, and it suits your needs. But if your datasource is huge, you would probably want to avoid it. A lot of times, people will handle QueryRowCount and explicitly set grid.ColCount as the columns may be few and fixed whereas the row count may be dynamic and vary significantly.
Anyway, to get changes in the number of rows or columns in your datasource to display properly, you can try calling grid.ResetVolatileData after you have changed them. If that is not sufficient, you can try calling grid.Refresh instead.
ADAdministrator Syncfusion Team August 19, 2004 12:22 AM
Of course I operate with QueryColCount and QueryRowCount, but the problem is:
I should somehow handle QueryCellInfo for column 23, after I reduce inner variable colcount from 23 to 15 and call grid.Refresh().
Cause I think Paint comes asinchronously to the grid. And it comes after I close settings form and before I call refresh :(
ADAdministrator Syncfusion Team August 19, 2004 01:09 AM
Are you change the column count on a different thread from thh the GridControl''s thread. If so, you should wrap teh virtual events in grid.InvokeRequired checks, and then do grid.Invoke if needed to call teh handler on the grid''s thread.
If you are not using separate threads, I am not sure why this problem would be happening. One thing you could try is that before you change 23 to 15, your datasource could raise an event that informs listeners that it is about to lower the column count. Then the grid could listen for this event, and try to handle any work it may need to do (like setting LeftColIndex so only ''good'' columns are visible, and maybe calling grid.CurrentCellMove to position the current cell away for a column that is no longer available after the event.)