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

Row Height Auto Resize with TextWrap

I have noticed a weird behaviour when a user enters multiple lines of text in a cell that has been set-up to allow auto resize and text wrapping. On the first line, wrapping to the second, the cell height changes only very slightly, like 1px, the first line disappears upwards, and the second line is in the position of the first line. From the second to third, and subsequent lines, the cell height changes correctly, displaying the previous line, as well as creating a new line. Why is there a problem with just the first line? Thanks, Adrian.

3 Replies

AD Administrator Syncfusion Team February 20, 2003 12:35 PM UTC

I think this is a bug that we will have to fix in our source. Here is a CurrentCellKeyPress event handler that you can try. Maybe it will give you better results than you are getting now.
private void gridControl1_CurrentCellKeyPress(object sender, System.Windows.Forms.KeyPressEventArgs e)
	GridCurrentCell cc = this.gridControl1.CurrentCell;
	GridStyleInfo style = this.gridControl1[cc.RowIndex, cc.ColIndex];
	if(style.AutoSize && style.WrapText)
		GridRangeInfo range = GridRangeInfo.Cell(cc.RowIndex, cc.ColIndex);
		int nOldHeight = this.gridControl1.GetRowHeight(cc.RowIndex);
		this.gridControl1.RowHeights.ResizeToFit(range, GridResizeToFitOptions.NoShrinkSize|GridResizeToFitOptions.ResizeCoveredCells);
		if(this.gridControl1.GetRowHeight(cc.RowIndex) != nOldHeight)

AL Adrian Launchbury February 21, 2003 03:28 AM UTC

Ok that worked a bit better, but I noticed that for each progressively wrapped line, the cell height resizes earlier and earlier. As a specific example, it will change the row height three characters earlier than the actual end of the line on the fourth wrapped line. Also when using the enter key to wrap onto a new line (first time only), it still rolls the text up instead of onto a new line. Though it does seem to create a new spare empty line after entering the second character on the previous line (delayed?) Also the ConfirmChanges() function doesn’t take an argument, so how did you compile your example, do you have a different version? I am using version

AD Administrator Syncfusion Team February 21, 2003 09:09 AM UTC

I am using the public patch available from your support home page.

Live Chat Icon For mobile
Up arrow icon