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

GGC table and nested table sizing

Hello, How would I automatically size the grid to the client width? I have found some code in the forum but it doesn''t handle the top level table properly nor does it handle the nested tables. The forum sample I''m referring to is http://www.syncfusion.com/Support/forums/message.aspx?MessageID=34801 Ultimately, I would like the nested tables to size to the client area which should line up exactly with the parent table. Regards, Mike

1 Reply

ST stanleyj Syncfusion Team January 12, 2006 10:04 AM UTC

Hi Mike, This code will work for nested tables also. this.gridGroupingControl1.GetTableModel("GrandChildTable").QueryColWidth += new GridRowColSizeEventHandler(TableModel_QueryColWidth); this.gridGroupingControl1.GetTableModel("ChildTable").QueryColWidth += new GridRowColSizeEventHandler(TableModel_QueryColWidth); this.gridGroupingControl1.TableModel.QueryColWidth += new GridRowColSizeEventHandler(TableModel_QueryColWidth); int indentCols; int ParentIndentColsCount; int ChildIndentColsCount; private void TableModel_QueryColWidth(object sender, GridRowColSizeEventArgs e) { GridTableModel gridModel = sender as GridTableModel; GridTableControl grid = (GridTableControl) gridModel.ActiveGridView; if (gridModel != null && grid != null) { int availableArea; indentCols = gridModel.GetColumnIndentCount() * gridGroupingControl1.TableOptions.IndentWidth; if(grid.TableDescriptor.Name == "GrandChildTable") { if(e.Index > gridModel.Cols.HeaderCount + gridModel.GetColumnIndentCount()-1) { availableArea = gridGroupingControl1.ClientSize.Width - gridModel.ColWidths.GetTotal(0, gridModel.Cols.HeaderCount)- indentCols - ParentIndentColsCount* gridGroupingControl1.TableOptions.IndentWidth - ChildIndentColsCount* gridGroupingControl1.TableOptions.IndentWidth; e.Size = (int)availableArea / (gridModel.ColCount-gridModel.GetColumnIndentCount()-1); e.Handled = true; } } else if(grid.TableDescriptor.Name == "ChildTable") { int startQueryFrom = gridModel.Cols.HeaderCount + gridModel.GetColumnIndentCount()-1; if(e.Index > startQueryFrom) { ChildIndentColsCount = gridModel.GetColumnIndentCount(); availableArea = gridGroupingControl1.ClientSize.Width - gridModel.ColWidths.GetTotal(0,gridModel.Cols.HeaderCount) - indentCols - ParentIndentColsCount* gridGroupingControl1.TableOptions.IndentWidth; e.Size = (int)availableArea / (gridModel.ColCount-gridModel.GetColumnIndentCount()); e.Handled = true; } } else { if(e.Index > gridModel.Cols.HeaderCount + gridModel.GetColumnIndentCount()-1) { ParentIndentColsCount = gridModel.GetColumnIndentCount(); availableArea = gridGroupingControl1.ClientSize.Width - SystemInformation.VerticalScrollBarWidth - indentCols; e.Size = (int)availableArea / (gridModel.ColCount-gridModel.GetColumnIndentCount()); e.Handled = true; } } } } Best regards, Stanley

Loader.
Live Chat Icon For mobile
Up arrow icon