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.
I''d like to dynamically set the initial width of columns in a GridDataBoundGrid based on the width of the header text OR the width of the longest string in the source data , whichever is longest. The grid is bound to a DataTable. Any suggestions?
ADAdministrator Syncfusion Team March 6, 2004 06:17 PM UTC
Try this after you have set the DataSource:
//turn off grid''s default sizing
this.grid.AllowResizeToFit = false;
//size things yourself
this.grid.Model.ResizeToFit(GridRangeInfo.Table(), GridResizeToFitOptions.IncludeHeaders);
KLKen LawMarch 13, 2004 09:49 AM UTC
Thanks - that works very well for my program.
Why is it necessary to set AllowResizeToFit = false? The call to ResizeToFit seems to work when this is set to true.
ADAdministrator Syncfusion Team March 13, 2004 11:01 AM UTC
By default, the GridDataBoundGrid tries to autosize the columns based on headertext. The AllowResizeToFit = false turns off this default sizing.
If you do not turn it off, the grid trying to size things based on headertext can step on any explicit sizing you try to do.