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

adjust the height and width of a cell in datagrid

hi I have a textbox with multiline = true and wrap = true with maxSize = 2000 Now this data is being saved into a cell of a datagrid I need to adjust the height and width of the cell(of datagrid) accordingly Can Some One Help me thanks Shri

6 Replies

AD Administrator Syncfusion Team August 9, 2004 03:24 PM UTC

To programatically size the row heights and colwidth, you call grid.Model.RowHeights.ResizeToFit and grid.Model.ColWidths.ResizeToFit. (If you are trying to do this from a point when the grid is not visibl, say in FormLoad, you should also set grid.AllowResizeToFit = false.)


SH Shri August 9, 2004 04:37 PM UTC

hi, Thanks! can i set minimum column size(width) so that when it auto resizes the column it doesnt go down certain value Shri


AD Administrator Syncfusion Team August 9, 2004 05:31 PM UTC

There is a GridResizeToFitOption.NoShrink flag you can pass when you call grid.Model.ColWidths.ResizeToFit to prevent the size from decreasing, but I do not think this is what you asked about when you mentioned mimum size. To impose a Minimum size, you would have to first call grid.Model.ResizeToFit and then have code like: Me.Grid.Model.ColWidths[3] = Math.Max(Me.Grid.Model.ColWidths[3], someMinValue) If it flickers too much, you can add a grid.BeginUpdate before you do teh resizing, and a grid.EndUpdate followed by grid.Refresh after the sizing code.


SH Shri August 9, 2004 07:08 PM UTC

hi, its working fine except the wrap property ie., if the user has not used the "Enter" key during input into the textbox.... and if the input is one long line then it should wrap itself at the max length of the cell and appear in the next line i tried other ways too but this is not working any suggestions thanks Shri


AD Administrator Syncfusion Team August 9, 2004 08:58 PM UTC

If you drag the row height larger, you should be able to see the multiple lines if you have style.WrapText = true. If you want to have the cell height autosize as you type into the cell, then try setting the style.AutoSize = true for that column.


AD Administrator Syncfusion Team August 10, 2004 11:35 AM UTC

thanks Shri

Loader.
Live Chat Icon For mobile
Up arrow icon