I did some more testing and subclassed C1FlexGrid and added an override of “CalculateCellHeight”. In there I printed the results.
Attached is an updated sample (performs “AutoSizeRows” only in row 5, where the problem occurs).
FlexGridRowHeight_2025-11-04.zip
The output of my debugging code is this:
CellHeight 5/0, measureSymbol = True: 17 (cell data: Musikhalle Komplett)
CellHeight 5/1, measureSymbol = True: 35 (cell data: 03:00-23:59
vor Buchung RS mit Frano)
CellHeight 5/2, measureSymbol = True: -1 (cell data: )
CellHeight 5/3, measureSymbol = True: -1 (cell data: )
CellHeight 5/4, measureSymbol = True: -1 (cell data: )
CellHeight 5/5, measureSymbol = True: 35 (cell data: 14:00-19:00 VA
Stadt Ludwigsburg Pensionärsfeier)
CellHeight 5/6, measureSymbol = True: 35 (cell data: 16:00-17:00 Abbau
FB 63 Bürgerbeteiligung)
CellHeight 5/7, measureSymbol = True: -1 (cell data: )
CellHeight 5/6, measureSymbol = False: 32 (cell data: 16:00-17:00 Abbau
FB 63 Bürgerbeteiligung)
RowHeight: 32
As you can see, it first measures each cell (which results in a reasonable value of “35” for row = 5 col = 6). Then it measures the last non empty cell in the row again and calculates “32”, which is the final row height.
The final “CalculateCellHeight” call has the parameter “measureSymbol = false”, while all others use “true”.
A workaround could be to ignore the “measureSymbol” parameter and set it always to “true”:
protected override int CalculateCellHeight(Graphics g, int row, int col, bool skipHidden, bool skipMerged, bool measureSymbol, out int symbolRight)
{
return base.CalculateCellHeight(g, row, col, skipHidden, skipMerged, measureSymbol: true, out symbolRight);
}
What do you think? Is this a reasonable workaround, or would it break other stuff? At least it results in slightly higher rows.
By the way: if I skip steps 1 and 2 in my initial list of steps to reproduce it and just click “Load 2” and “AutoSizeRows”, it prints heights of “36” and “33”, which is one more pixel. This one additional pixel makes the cell content render completely. But why does “CalculateCellHeight” return different values in this situation?
Best regards
Wolfgang