[Lazarus] Is there aTDBLabel?

Frans fjf.vanleeuwen at quicknet.nl
Wed Mar 9 20:43:13 CET 2016


Hi

I use Lazarus 1.6 on Windows 7.
I've used lazdatadesktop to change the Displaylabel of the DB fields. In a DBGrid that new names 
popup as the column names. But in a form with TDBEdit fields I can't use a TDBLabel that 
automatically takes the name from the associated Control as the caption. Instead, I placed TLabel 
components and made the following method:

procedure TMyForm.FormShow(Sender: TObject);
var
   l: TLabel;
begin
   for TComponent(l) in Self do
   begin
     if (l is TLabel) and (l.FocusControl is TDBEdit) then
       l.Caption := TDBEdit(l.FocusControl).Field.DisplayLabel;
     if (l is TLabel) and (l.FocusControl is TDBLookupComboBox) then
       l.Caption := TDBLookupComboBox(l.FocusControl).Field.DisplayLabel;
   end;
end;

It works. But still I wonder, is there a another way? I've tried TDBText but that shows th field 
value, not the DisplayLabel.

-- 
mvg
Frans van Leeuwen
M 06-51695390





More information about the Lazarus mailing list