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.
When one double-clicks on the right edge of the column header in Excel, that column does a resize to fit so that the longest piece of data in one of the cells is visible.
The same thing applies to row heights. And if one selects the entire grid and double-clicks an edge then all the columns and all the rows resize to fit.
I’ve found that while this behavior also occurs in the Grid, it is not quite as expected. In most cases it does the opposite. Rather than resizing to fit that long piece of data, it will collapse the column (or row) to some predetermined, smaller width (height). The times I have seen it actually expand a column, said column was already wide enough to display the data but the Grid expanded a little more to give it some nice padding. And there isn’t any expand all functionality [not so much of a problem but I just wanted to note it in this comparison].
So, is there any workaround code to trap for this double-click on column/row header edge event and programmaticly behave like Excel? Or, is this a bug I should report on Direct-Track? Or, all of the above?
Thanks,
Tom
ADAdministrator Syncfusion Team May 16, 2003 08:09 PM UTC
The grids default behavior is to reset the column width or row height back to its original value (as specified with Cols.DefaultSize).
There is no property to change this behavior but you can change it by subscribing to the ResizingCols/ResizingRows event.
private void gridControl1_ResizingColumns(object sender, GridResizingColumnsEventArgs e)
{
if(e.Reason == GridResizeCellsReason.DoubleClick)
{
this.gridControl1.ColWidths.ResizeToFit(e.Columns, GridResizeToFitOptions.IncludeHeaders);
e.Cancel = true;
}
}
Alternatively, you could do ColWidths.ResizeToFit only for the visible rows.
Stefan