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. (Last updated on : November 16, 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Words being split when Text wrapping enabled

Thread ID:

Created:

Updated:

Platform:

Replies:

12082 Mar 22,2004 08:50 AM UTC Mar 22,2004 01:03 PM UTC WinForms 3
loading
Tags: GridControl
Samuel Jack
Asked On March 22, 2004 08:50 AM UTC

I have Word Wrapping enabled on my header row. I want the header columns to be taller rather than wider when they contain a lot of text. So first of all I call _grid.RowHeights.ResizeToFit(GridRangeInfo.Row(TitleRow), GridResizeToFitOptions.IncludeHeaders); then I call _grid.ColWidths.ResizeToFit(GridRangeInfo.Cols(0, _grid.ColCount), GridResizeToFitOptions.IncludeHeaders); This mostly works. The only exceptions are columns which contain some long words like "Randomness", "Percentage". These words tend to have the last few letters sent to the next line. Is this a bug, or is there an option I can set to prevent these words from being split and instead have the column made wider. I can''t really do a test on individual columns because the grid is being used generically - the column headers can change each time it''s used. Thanks, Sam

Administrator [Syncfusion]
Replied On March 22, 2004 09:52 AM UTC

One comment is that you are sizing the Colwidths on the whole grid and not just teh header row. (I don''t think this is causing the problem you are having, but just wanted to make sure this is what you want to do.) There is no property setting that will handle this problem. The only way I would know to get this done is to write a method that accepts your header string, and returns a string that has Environment.NewLine''s exactly where you want the breaks to be in the header. Then you could replace the old header text with this new headertext. Then if you call ColWidths.ResizeToFit followed by RowHeightsResizeToFit, I think you would get the behavior you want.

Administrator [Syncfusion]
Replied On March 22, 2004 11:05 AM UTC

>There is no property setting that will handle this problem. The only way I would know to get this done is to write a method that accepts your header string, and returns a string that has Environment.NewLine''s exactly where you want the breaks to be in the header. Then you could replace the old header text with this new headertext. Then if you call ColWidths.ResizeToFit >followed by RowHeightsResizeToFit, I think you would get the behavior you want. > > The problem is not about where new lines are occuring. It is about ResizeToFit on Columns not working correctly: not enough space is being allowed for long words, so that for example when the word "Randomness" should be given enough space to fit on one line, the last "s" is moved onto the next line

Administrator [Syncfusion]
Replied On March 22, 2004 01:03 PM UTC

I understand the problem is the colwidth is not large enough. To get the wrapped text, you have to specify a width. To get the optimal width, you have to know the wrapped text. I think it is a chicken and egg problem. We have not attempted to resolve this problem in our code. We have no algorythm implemented for dynamic wordwrapping with respect for optimal column sizing. To get what you want, I think you will have to call ColWidths.ResizeToFit first. This fixes that column width. Then call RowHeights.ResizeToFit to fix the rowheight based on the column width. To have the absolute narrowest column, I think you will have to go through header text and put hard breaks(Environment.NewLine) in the text. You can do this programatically. This will make calling ColWidths.ResizeToFit size the column width to the size you require. Another option is to derive the cell control and override the CalculatePreferredCellSize in the model. This will allow you to define the ''optimal'' size of your cell. But you would have to handle the dynamic wordwrapping/optimal width problem (which you could do by using the the longest word to define your optimal with as in teh first suggestion. But a general solution probably cannot assume the optimal width should exactly handle the longest word).

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;