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

Increase rowheight automatically to max in a GridDataBoundGrid

I try to increase the height of a row in a GridDataBoundGrid to max necessary right after loading. There's just one column in the row and the cells can contain several lines. So it would be very nice, if all lines in every cell will be displayed at startup. The TableStyle.AutoSize property increases automatically the height of the row, when text in a cell is edited. But what do I have to do to get this right after the form is loaded? In MS environment, a doubleclick on the boarder of a column or a row header will in- or decrease the column width/row height to the necessary. Could you please also tell me, who I can handle this? Thanks.

6 Replies

AD Administrator Syncfusion Team January 22, 2003 01:54 PM

First, make sure that GridDataBoundGrid.AllowResizeToFit is set to false. If this is true, the grid will try autosize columns widths based on the header cells. This may undo any other sizing you may have done. Then use the ResizeToFit call to size the range you are interested in. So, to autosize all the rowheights in your grid, in form_load, try this.gridDataBoundGrid.Model.RowHeights.ResizeToFit(GridRangeInfo.Table(),GridResizeToFitOptions.NoShrinkSize);


CC Charles Carlin January 24, 2003 12:53 PM

I was doing this successfully with some multi line entries in the grid and all was working fine until I decided to switch to an embedded grid control (which looks and works great by the way). Now I basically have an embedded grid (one column with image and text on multiple rows) in one of my grids columns (on every row). However now the resize code doesn't recognize the embedded grids size. Is there anyway to modify the GridinCell class so it will work with the ResizeToFit method?


AD Administrator Syncfusion Team January 24, 2003 03:44 PM

Hi Chuck, you can override the OnQueryPrefferedClientSize method of the cell model (see GridCellModelBase class reference). This method will be called to determine the correct size of the cell when ResizeToFit is called. Stefan


BO Bruce Onder February 16, 2003 06:54 PM

I'm having a bit of a challenge performing the following: My client application has an order entry grid that users can type a product number into one column, and then I pre-fill the majority of the rest of the columns for that row -- product description, etc. For some products, the default height of the row is enough to display the full product. However, for some products the description is cut off, and I need to change the rowheight to display the full description. I have tried the comments in this thread, but I am not getting any resize to occur. Any thoughts?


AD Administrator Syncfusion Team February 16, 2003 07:04 PM

After you fill the row with data you should call RowHeights.ResizeToFit(GridRangeInfo.Row(rowIndex), GridResizeToFitOptions.NoShrinkSize); The cells should have style.WrapText = true set. Stefan


SW Scott Wheeler March 11, 2014 05:00 PM

Ha! This post was helpful even 11 years later. Thanks!

Loader.
Live Chat Icon For mobile
Up arrow icon