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

GridGroupingControl sizing

I have a GGC in a user control, docked to Fill. I''d like to be able to expand the last column of the grid to fit the width of the user control without showing a horizontal scrollbar only if the grid doesn''t fill the entire width when I bind to my datasource. If the total column widths equals or exceeds the width of the grid control, then behave as normal. Any ideas how to do this? I''ve tried several things without success...

1 Reply

AD Administrator Syncfusion Team September 7, 2004 12:17 PM UTC

Hi Mike, You can handle the QueryColWidth event of the TableModel as follows and also set SmoothControlResize = false. this.gridGroupingControl1.TableModel.QueryColWidth += new GridRowColSizeEventHandler(TableModel_QueryColWidth); this.gridGroupingControl1.TableModel.Options.SmoothControlResize = false; bool fillLastColumn = true; private void TableModel_QueryColWidth(object sender, GridRowColSizeEventArgs e) { GridTableModel gridModel = sender as GridTableModel; GridTableControl grid = (GridTableControl) gridModel.ActiveGridView; if (gridModel != null && grid != null) { int lastColIndex = gridModel.ColCount-2; // GridTableModel always has one two empty extra column at end if (this.fillLastColumn && e.Index == lastColIndex) { int width = gridModel.ColCount <= 0 ? 0 : gridModel.ColWidths.GetTotal(0, lastColIndex-1); e.Size = grid.ClientRectangle.Width-width; e.Handled = true; } } } I attached a sample project. AutoFillLastColumn_5112.zip Stefan

Live Chat Icon For mobile
Up arrow icon