We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

column width setting using ResizeToFit

We use this.Model.ColWidths.ResizeToFit(GridRangeInfo.Rows(0, 100), GridResizeToFitOptions.IncludeHeaders) to set the column width automatically, however, we still need to add more space for the width of header cell. It''s possible to get it by setting the border like: this.RowStyles[0].BorderMargins.Right = 20;this.RowStyles[0].BorderMargins.Left = 20; Thanks.

1 Reply

AD Administrator Syncfusion Team January 5, 2006 07:27 AM UTC

Hi Hui, BorderMargins are for cell''s internal borders. If the border margin is set for an editable cell then effect can be seen in the current cell''s border. this.gridDBG.Model.ColStyles[1].BorderMargins.Right = 20; To size the column beyond its default width, then you may use ColWidths properties or handle in QueryColWidth handler, but to use Colwidths property, AllowResizeToFit has to be set to false. private void Model_QueryColWidth(object sender, GridRowColSizeEventArgs e) { if(e.Index == this.grid.Binder.NameToColIndex("columnName")) { e.Size = 100; e.Handled = true; } } Also refer this KB: http://www.syncfusion.com/support/kb/grid/Default.aspx?ToDo=view&questId=304 to see if that helps. Regards, Calvin.

Loader.
Live Chat Icon For mobile
Up arrow icon