BoldDeskWe are launching BoldDesk on Product Hunt soon. Learn more & follow us.
private void OnGridQueryCellInfo(object sender, GridQueryCellInfoEventArgs e) { ... var size = e.Style.CellModel.CalculatePreferredCellSize(e.Cell.RowIndex, e.Cell.ColumnIndex, e.Style, GridQueryBounds.Width); if (size.Width > grid.ColumnWidths[e.Cell.ColumnIndex]) { grid.ColumnWidths[e.Cell.ColumnIndex] = size.Width; } }
Hi Craig,
Thank you for using syncfusion products.
We have analyzed your query. You can achieve your requirement by using ResizeColumnsToFit() like the below code snippet.
Code Snippet:
private void Button_Click(object sender, RoutedEventArgs e) { var row = this.grid.CurrentCell.RowIndex; var col = this.grid.CurrentCell.ColumnIndex; this.grid.Model.ResizeColumnsToFit(GridRangeInfo.Cell(row,col),GridResizeToFitOptions.None); this.grid.InvalidateVisual(true); } |
We have also prepared a simple sample based on your requirement. Please find the attachment below
Please let us know if you have any queries.
Thanks
Kanimozhi B
Hi Craig,
Apologize for the delay.
We have analyzed your query. But Currently GridControl do not have support to adjust the column width in QueryCellInfo event or any other subsequent events. However you can resize the particular cell by calling ResizeColumnsToFit method by passing argument as particular range instead of passing whole column or table like the below snippet as we have already explained in previous update.
this.grid.Model.ResizeColumnsToFit(GridRangeInfo.Cell(row,col),GridResizeToFitOptions.None); |
Please let us know if you have any queries.
Thanks
Kanimozhi B