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

Grid to Extend entire Area

Hi All,

Is there any way to make the DataGrid "FILL"
the entire page even when the grid s smaller than
the area it occupies ? Even if I dock the control as a "Fill" there is unused space if the
data is not enough to fill the grid. Can I auto
expand the length and width so the GRID takes
up all usuable space.

Rick

1 Reply

RA Rajagopal Syncfusion Team March 26, 2007 06:58 PM UTC

Hi Rick,

You can resize the columns and rows to fit over the grid's entire area, by handling the Grid.Model.QueryColWidth and Grid.Model.QueryRowHeight respectively. Below are the code snippets that helps in doing this.

private void Model_QueryColWidth(object sender, GridRowColSizeEventArgs e)
{
if(e.Index > this.gridDataBoundGrid1.Model.Cols.HeaderCount)
{
int clientwidth = this.gridDataBoundGrid1.ClientRectangle.Width - this.gridDataBoundGrid1.Model.ColWidths[0];
e.Size = (int)(clientwidth / (float)this.gridDataBoundGrid1.Model.ColCount);
e.Handled = true;
}
}

private void Model_QueryRowHeight(object sender, GridRowColSizeEventArgs e)
{
if(e.Index > this.gridDataBoundGrid1.Model.Cols.HeaderCount)
{
int clientheight = this.gridDataBoundGrid1.ClientRectangle.Height - this.gridDataBoundGrid1.Model.RowHeights[0];
e.Size = (int) ( clientheight / (float) this.gridDataBoundGrid1.Model.RowCount );
e.Handled = true;
}
}

Regards,
Rajagopal

Loader.
Live Chat Icon For mobile
Up arrow icon