The Syncfusion® native Blazor components library offers 70+ UI and Data Viz web controls that are responsive and lightweight for building modern web apps.
.NET PDF framework is a high-performance and comprehensive library used to create, read, merge, split, secure, edit, view, and review PDF files in C#/VB.NET.
Hi,
I'm implementing a grid that derive from the VirtTreeGrid.
I'd like to resize the columns to fit. Normally I should use:
gridControl1.ColWidths.ResizeToFit(GridRangeInfo.Col(1));
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.
Thanks,
Sebastien
CBClay Burch Syncfusion Team July 18, 2002 03:09 PM UTC
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.