[Lazarus] Is there aTDBLabel?
fjf.vanleeuwen at quicknet.nl
Wed Mar 9 21:04:40 CET 2016
Thanks Michael, I will do the same. And the use of colors is very nice.
Frans van Leeuwen
Op 09-03-2016 om 20:59 schreef Michael Van Canneyt:
> On Wed, 9 Mar 2016, Frans wrote:
>> 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);
>> l: TLabel;
>> for TComponent(l) in Self do
>> 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;
>> It works. But still I wonder, is there a another way? I've tried TDBText but that shows th field
>> value, not the DisplayLabel.
> There is no standard control for it. But it should in fact be easy to add to
> the LCL.
> I have a very large application in which I do the same, but I had to develop
> my own TLabel subclass for this. (It also switches color when the field is
> required etc.)
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
More information about the Lazarus