[Lazarus] Updating a field from an OnEditButtonClick event
Luca Olivetti
luca at wetron.es
Thu Jun 30 10:13:21 CEST 2011
Al 29/06/2011 17:53, En/na Julio César Gázquez ha escrit:
> However, I found that in the OnEditButtonClick event I can't put the
> dataset in dsEdit state, the Edit procedure has no visible effect and
> the field assignment triggers an exception.
>
> The same event handler attached to a regular button OnClick event works
> as intended. The dataset is a Zeos TZQuery, but I'm not sure if this
> could happen on a different kind of dataset.
>
> Is this a known or expected behavior? There is a workaround?
Works here, lazarus 0.9.30, fpc 2.4.2, zeos 6.6.4 (with some local
modifications to make it compile under current lazarus).
(In my program I used a TRxDBGrid, and I'm quite pissed that now the
headings are awful, but I also tested with a plain TDbGrid).
FYI, my event handler (the column contains a color):
procedure TMainForm.GridPantallasEditButtonClick(Sender: TObject);
var
f:TLongintField;
begin
if copy(GridPantallas.SelectedField.FieldName,1,6)='color_' then
begin
f:=TLongintField(GridPantallas.SelectedField);
ColorDialog1.Color:=f.value;
if ColorDialog1.Execute and (ColorDialog1.Color<>f.value) then
begin
if not (QueryPantallas.State in dsWriteModes) then
QueryPantallas.Edit;
f.value:=ColorDialog1.Color;
PruebaColor;
end;
end;
end;
Bye
--
Luca Olivetti
Wetron Automation Technology http://www.wetron.es
Tel. +34 935883004 (Ext.133) Fax +34 935883007
More information about the Lazarus
mailing list