Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2003-09

FCL TField.GetCanModify wrong?

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andrew Johnson

I have been trying to make a db-aware edit control for the lcl and getting nowhere and its as far as I can tell because Field.GetCanModify is always false so it is never editable. Looking through the fcl sources I find this function -

function TField.GetCanModify: Boolean;
begin
  Result:=Not ReadOnly;
  If Result then
    begin
    Result:=Assigned(DataSet);
    If Result then
      Result:=Not(DataSet.CanModify);
    end;
end;

and since Datset.CanModify is almost always going to be true, if editing then this always validates false. in fact right now that function always returns true anyway. so this will always be wrong. I think it should be

    If Result then
      Result:= DataSet.CanModify;

I worked passed this for now by using my own routine which does the test like this and it works fine for me.

Andrew

Reply by email

Unknown author
to Andrew Johnson
Andrew Johnson wrote 26 lines
I have been trying to make a db-aware edit control for the lcl and getting nowhere and its as far as I can tell because Field.GetCanModify is always false so it is never editable. Looking through the fcl sources I find this function - function TField.GetCanModify: Boolean; begin Result:=Not ReadOnly; If Result then begin Result:=Assigned(DataSet); If Result then Result:=Not(DataSet.CanModify); end; end; and since Datset.CanModify is almost always going to be true, if editing then this always validates false. in fact right now that function always returns true anyway. so this will always be wrong. I think it should be If Result then Result:= DataSet.CanModify; I worked passed this for now by using my own routine which does the test like this and it works fine for me.

You are of course right. I have adapted the sources accordingly, and committed in CVS.

Michael.

Reply by email