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

sizing child grid to fit window

Hi, I have a parent grid that fits correctly within the window, but the child grid requires the user to scroll to the right to view all of the fields. Is there some way to: 1.Fit the child grid to the window 2.Exands all of the child columns to the max width allowable while still fitting the grid to the window. Thanks

7 Replies

AD Administrator Syncfusion Team February 5, 2004 05:18 PM UTC

Take a look at this sample. It uses the grid.Model.QueryColWidth event to proportionly size the grid columns as you size the grid. Syncfusion\Essential Suite\Grid\Samples\DataBound\GridDataBoundImageCell


AD Administrator Syncfusion Team February 5, 2004 05:34 PM UTC

Thanks, that worked partially, but now the column headings are being compressed to meet the new column sizes. Is there a way to have the column size to whatever is widest; heading or text? >Take a look at this sample. It uses the grid.Model.QueryColWidth event to proportionly size the grid columns as you size the grid. > >Syncfusion\Essential Suite\Grid\Samples\DataBound\GridDataBoundImageCell


AD Administrator Syncfusion Team February 5, 2004 05:54 PM UTC

If you use proportion sizing, you will likely see header text not fitting. So, another techique is to size the right-most column to fill up any empty space. This will let the default sizing (or explicit sizing if you want it) work for the other columns. You would also do this in QueryColWidth. Here is a forum link that discusses this. http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=2699


AD Administrator Syncfusion Team February 5, 2004 07:30 PM UTC

Hi, I used the code in the example, and its not working. Here is the code I have: Private Sub GetColWidth(ByVal sender As Object, ByVal e As GridRowColSizeEventArgs) Dim fillLastColumn As Boolean = True If fillLastColumn AndAlso e.Index = Me.elementGrid2.Model.ColCount Then Dim width As Integer = IIf(Me.elementGrid2.Model.ColCount <= 0, 0, Me.elementGrid2.Model.ColWidths.GetTotal(0, Me.elementGrid2.Model.ColCount - 1)) e.Size = Me.elementGrid2.ClientRectangle.Width - width e.Handled = True End If The grid has 14 columns but the e.Index value never goes above ''2'' so the code does not run. Any help would be appreciated. >If you use proportion sizing, you will likely see header text not fitting. So, another techique is to size the right-most column to fill up any empty space. This will let the default sizing (or explicit sizing if you want it) work for the other columns. You would also do this in QueryColWidth. Here is a forum link that discusses this. > >http://www.syncfusion.com/Support/Forums/message.aspx?MessageID=2699


AD Administrator Syncfusion Team February 5, 2004 09:28 PM UTC

Here is a sample. 10560_8253.zip


AD Administrator Syncfusion Team February 5, 2004 10:17 PM UTC

THanks for the sample, but I already tried that method. The problem is that the e.index value never goes above 2 and my grid colcount = 14. I''m not sure why this is, but any insight would be helpful >Here is a sample. >10560_8253.zip > >


AD Administrator Syncfusion Team February 6, 2004 07:36 AM UTC

Th reason e.Index never gets higher than 2 is that your client area will not hold 2 columns. If you want to see all the columns, no matter what the size of the client area, then you will have specially size each column down to some size that will allow all the columns to be visible in the given client area. One way to do this is to use the proportional sizing. The fillrightcolumn only makes sense if you know your client area is large enough to see all the columns. This means that it is likely you will not be able to see the full header text for every column. Exactly how you want to handle this is up to you. Wrap the headerText and do not change the row height? Wrap the heatertext and resize the row height so you see it all? Do not wrap the header text, clipping it instead? Or, something else? You can do any of these thing as well as other things, but fully seeing every header text on a single line is only possible if you make sure your client area is large enough to make this possible. Here is a sample showing the above options. 10560-1_1023.zip

Loader.
Live Chat Icon For mobile
Up arrow icon