this.sfDataGrid.GridColumnSizer = new GridColumnSizerExt(sfDataGrid);
public class GridColumnSizerExt : GridColumnSizer
{
SfDataGrid sfDataGrid;
public GridColumnSizerExt(SfDataGrid dataGrid)
: base(dataGrid)
{
sfDataGrid = dataGrid;
}
protected override Size MeasureText(Size rectangle, string displayText, GridColumn column, object record, GridQueryBounds queryBounds)
{
if (queryBounds == GridQueryBounds.Height)
sfDataGrid.GridColumnSizer.Margin = new Thickness(3, 1, 3, 1);
else if (queryBounds == GridQueryBounds.Width)
sfDataGrid.GridColumnSizer.Margin = new Thickness(5, 1, 5, 1);
return base.MeasureText(rectangle, displayText, column, record, queryBounds);
}
} |
Queries |
Solutions |
I can confirm this workaround works. Would be nice to have this fixed in your code. |
We have checking feasibility include fix in our SfDataGrid source architecture and we will update you the details on June 10, 2020. |
how to set GridColumnSizer.FontFamily globally for the whole app? Or I need to set it for all grids individually? |
Yes you need to set individual grid for SfDataGrid.GridColumnSizer.FontFamily in your application. Please refer the below user documentation for more details, UG Link: https://help.syncfusion.com/wpf/datagrid/autosize-columns#changing-font-settings-for-one-column |