Hi, I'm trying to display a fixed grid meaning I have fixed columns size in a UltraWebGrid, the problem is that some fields doesn't display the whole text, I notice a property that says "wrap" but I set it true and I still get the same result:
How can I approach this??? can anybody help me whit this?
Thanks
Thanks for the answer, in fact, that was exactly what I needed, latter I realized that the wrap thing is working because the other cells where cutting the content and putting it into separate lines inside the cell, but as you say, it works only with words... I deal whit it by cutting the word before sending it to the cells and I works, at least for me...
Thanks a lot!
Having pre-determined the column width for each cell (each cell being the same size), and set the relevant row size manually elsewhere I am using this function while iterating through each cell to modify the text:
private void AutoWrapCellContents(ref UltraGridCell cell) { // Modify the label, by inserting a white space to wrap the label down if necessary int fontWidth = 9; int lineBreaks = (cell.Value.ToString().Length * fontWidth) / (cell.ColSpan * _DataColumnWidth); int charCountPerLine = (cell.ColSpan * _DataColumnWidth) / fontWidth;
string newLabel = ""; int charCount = 0;
if (lineBreaks > 0) { foreach (char nextChar in cell.Value.ToString()) { charCount++; newLabel += nextChar;
if (charCount == charCountPerLine) { newLabel += " "; charCount = 0; } }
cell.Value = newLabel; }
Fixed grids can't wrap their text by 'characters' only by word. There is another post about this somewhere that I ran into yesterday.
I am working on exactly the same issue as you - but I am performing ALL of the rendering as I am not using a conventional data structure to create my grid, as it's a proprietry data structure that the Grid would never understand.
The only way to get round this, is to modify your text and insert a white-space (I used a simple space character) at the point you need to the grid to wrap, and you may also need to modify the height of each row appropriately. You may also need to use both the Column.Wrap and Row.Wrap properties to deal with this more effectively for you.
The only problem I have run into so far, is knowing what font has been applied so I can set the whitespace point in the right place, as I can't seem to query this from anywhere on the grid (DisplayLayout, Column etc all have the Font set to nothing).