style.AutoSize only works for key board input. It allows for adjusting cells as your user types.
If you want to programatically autosize things, then you would explicitly call grid.Model.RowHeights.ResizeToFit and grid.Model.ColWidths.ResizeToFit.
Doubling clicking a header cell border does not set the optimal size. Instead it sets the default size. So, if you user has been changing his colwidths, he can double click the border to reset things back to the default. The code tries to auto
If you want the doubleclick to behave differently, you can handle this event.
private void gridControl1_ResizingColumns(object sender, GridResizingColumnsEventArgs e)
{
if(e.Reason.Equals(GridResizeCellsReason.DoubleClick))
{
GridRangeInfo range = e.Columns;
this.gridControl1.Model.ColWidths.ResizeToFit(range,
GridResizeToFitOptions.IncludeHeaders);
e.Cancel = true;
}
}
If you have a many rows, then ResizeToFit will visit each row to compute the optimal size, and this may be time consuming. So, you may want to restrict the resizing to the visible grid (grid.ViewLayout.VisibleCellsRange) or in some other manner.