mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-05 10:18:17 +02:00
LCL, fix several db controls to not enter dataset in edit state if datasource.autoedit is false, issue #8739
git-svn-id: trunk@11066 -
This commit is contained in:
parent
920d0c3b8e
commit
15f7db6d03
@ -494,6 +494,7 @@ Type
|
||||
procedure FocusRequest(Sender: TObject); virtual;
|
||||
procedure Loaded; override;
|
||||
procedure EditingDone; override;
|
||||
procedure UpdateText;
|
||||
public
|
||||
constructor Create(TheOwner: TComponent); override;
|
||||
destructor Destroy; override;
|
||||
|
@ -1533,16 +1533,12 @@ begin
|
||||
|
||||
SelField := SelectedField;
|
||||
TempColumn := TColumn(ColumnFromGridColumn(Col));
|
||||
if (TempColumn<>nil) and not TempColumn.ReadOnly then
|
||||
if (TempColumn<>nil) and not TempColumn.ReadOnly and FDatalink.Edit then
|
||||
begin
|
||||
if SelField.DataType=ftBoolean then
|
||||
begin
|
||||
SelField.DataSet.Edit;
|
||||
SelField.AsBoolean := not SelField.AsBoolean
|
||||
end
|
||||
else
|
||||
begin
|
||||
SelField.DataSet.Edit;
|
||||
if ValueMatch(TempColumn.ValueChecked, SelField.AsString) then
|
||||
SelField.AsString := TempColumn.ValueUnchecked
|
||||
else
|
||||
|
@ -149,9 +149,11 @@ end;
|
||||
|
||||
procedure TDBCheckBox.EditingDone;
|
||||
begin
|
||||
FDatalink.Edit;
|
||||
FDatalink.Modified;
|
||||
FDataLink.UpdateRecord;
|
||||
if FDatalink.Edit then begin
|
||||
FDatalink.Modified;
|
||||
FDataLink.UpdateRecord;
|
||||
end else
|
||||
State:=GetFieldCheckState;
|
||||
inherited EditingDone;
|
||||
end;
|
||||
|
||||
|
@ -36,10 +36,12 @@ begin
|
||||
//need to override this to make sure the datalink gets notified
|
||||
//its been modified, then when post etc, it will call
|
||||
//updatedata to update the field data with current value
|
||||
FDatalink.Edit;
|
||||
FDataLink.Modified;
|
||||
|
||||
inherited Change;
|
||||
if FDatalink.Edit then
|
||||
begin
|
||||
FDataLink.Modified;
|
||||
inherited change;
|
||||
end else
|
||||
UpdateText;
|
||||
end;
|
||||
|
||||
|
||||
@ -69,15 +71,9 @@ end;
|
||||
|
||||
procedure TDBComboBox.DataChange(Sender: TObject);
|
||||
begin
|
||||
if not (Style=csSimple) and DroppedDown then Exit;
|
||||
if FDataLink.Field <> nil then
|
||||
// ToDo: use Field.Text
|
||||
Text := FDataLink.Field.DisplayText
|
||||
else
|
||||
if csDesigning in ComponentState then
|
||||
Text := Name
|
||||
else
|
||||
Text := '';
|
||||
if not (Style=csSimple) and DroppedDown then
|
||||
Exit;
|
||||
UpdateText;
|
||||
end;
|
||||
|
||||
procedure TDBComboBox.EditingChange(Sender: TObject);
|
||||
@ -123,6 +119,18 @@ begin
|
||||
inherited EditingDone;
|
||||
end;
|
||||
|
||||
procedure TDBComboBox.UpdateText;
|
||||
begin
|
||||
if FDataLink.Field <> nil then
|
||||
// ToDo: use Field.Text
|
||||
Text := FDataLink.Field.DisplayText
|
||||
else
|
||||
if csDesigning in ComponentState then
|
||||
Text := Name
|
||||
else
|
||||
Text := '';
|
||||
end;
|
||||
|
||||
procedure TDBComboBox.ActiveChange(Sender: TObject);
|
||||
|
||||
begin
|
||||
|
@ -157,7 +157,11 @@ begin
|
||||
//so if a user changed the selection it can be
|
||||
//updated, and if not canel out ala ReadOnly
|
||||
if not FDataLink.Edit then
|
||||
begin
|
||||
// restore value
|
||||
DataChange(self);
|
||||
exit;
|
||||
end;
|
||||
|
||||
inherited Click;
|
||||
FDataLink.Modified;
|
||||
|
@ -141,8 +141,10 @@ begin
|
||||
Value := GetButtonValue(ItemIndex);
|
||||
if (Value<>OldValue) and FDatalink.CanModify and not SettingValue then
|
||||
begin
|
||||
FDatalink.Edit; // ensure that we are in edit state
|
||||
FDataLink.Modified;
|
||||
if FDatalink.Edit then // ensure that we are in edit state
|
||||
FDataLink.Modified
|
||||
else
|
||||
DataChange(Self);
|
||||
end;
|
||||
end;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user