[Lazarus] Increasingly frustrated with DbGrids

Luca Olivetti luca at wetron.es
Mon Nov 2 11:12:08 CET 2015


Hello,

I constantly stumble with the behaviour of the TDBGrid.
I understand that it's a complex component, but every time I find an 
issue an Luiz fixes it, two more pop up (or an older one resurfaces).
The latest episode of the saga is the futility of using a custom editor 
(with OnSelectEditor), since the grids then sets the value of the field 
using this snippet of code

   if (FEditor<>nil) and FEditor.Visible then begin
     Msg.LclMsg.msg:=GM_GETVALUE;
     Msg.grid:=Self;
     Msg.Col:=FCol;
     Msg.Row:=FRow;
     Msg.Value:=GetCells(FCol, FRow);
     FEditor.Dispatch(Msg);
     SetEditText(Msg.Col, Msg.Row, Msg.Value);
   end;

and this only works with the editors defined in Grids.pas, the only ones 
managing the GM_GETVALUE message.
For other kinds of editors the result depends on how you move in the 
grid: it could either maintain the value the editor set or reset it to 
an empty string.

I think I will file a bug once I can create a simple project, but in the 
meantime if somebody has an idea on how to solve it, it would be 
appreciated.

Oh, and a custom editor has no way of adapting if the dbgrid is 
scrolled, a column is resized, etc. Again, this only work for the 
editors defined in Grids.pas.

Bye
-- 
Luca Olivetti
Wetron Automation Technology http://www.wetron.es/
Tel. +34 93 5883004 (Ext.3010)  Fax +34 93 5883007




More information about the Lazarus mailing list