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...
ADAdministrator Syncfusion Team September 7, 2004 08:17 AM
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.