The right way to handle variable heights of DBGrid rows lazarus / 31-LCL ---------------------------------------------------------------------- j111 · 2012-05-28 17:27 Good evening! Sample project, covered this message theme is attached to the post. Screenshot that illustrates problem is attached too. I went into task of displaying multiline text in DBGrid cells and have success, but some features of the DBGrid scrolling is out of my understanding. If describe problem in short it lies in strange scrolling behaviour - sometimes, selected row may be invisible for user, because it locates under DBGrid viewport or DBGrid can fill with records only half of visible area. The code is very simple to understand: 1. TMyDBGrid is descendant of TCustomDBGrid, that overrides  PrepareCanvas procedure 2. Within PrepareCanvas routine I set TextStyle with SingleLine=False and WrodBreak=True fields and also calculate dimentions of rectangle that can hold multiline cell text. 3. Height of text I strore in corresponding element of RowHeights array. All text appears multiline and well formated, but if you look at screenshot the two facts are obvious: selected row can be displayed under the bottom of the visible part of grid and grid itself sometimes displayed half filled. So, the problem now: what things should I change to have correct scrolling. ---------------------------------------------------------------------- KpjComp · 2012-05-29 00:01 I think variable heights in a TDbGrid might be a little tricky.  This is because as you page in the next set of records, they could all be different heights again.  Normally you would just make the DefaultHeight of the grid larger so that you could do multiple lines. Another option if there are not too many records is to use a TStringGrid/TDrawGrid, first traverse you Dataset and calculate the heights of all records and fill the RowHeights array.  You then simply implement a DrawCell event. Also I think because your currently altering the RowHeights on the PrepareCanvas virtual method, your confusing the TDbGrid and is the reason focused records can appear partial.