I'm implementing a grid that derive from the VirtTreeGrid.
I'd like to resize the columns to fit. Normally I should use:
A solution could be to use the event QueryColWidth but how can I do that. If I use the ResizeToFit at this position, I get a StackOverflowException.
CBClay Burch Syncfusion Team July 18, 2002 11:09 AM
You can remove the handler QueryColWidths and just let the grid store the colwidths for you. In this case, you would explicitly set the colwidths whenever you needed to do it. If you wanted it to be dynamic, autosizing a particular column using ResizeToFit, that should probably work. You might try it at the bottom of Form_Load after the data has been created and after the event handlers have been hooked. If you are trying to fit the cell with the indentation, you would have to increase the width by the max number of indents. You could call ResizeToFit, and then get the ColWidth of that column and increase it by extra space.
You do not want to call a method like ResizeToFit from any of these Query... events as this is a fairly expensive call, and the query events can be hit often. And then you have the recursive call problem as well.