TsCustomNumEdit.SetText does no validity check

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #69710
    HeDiBo
    Participant

      I think the procedure should read:

      procedure TsCustomNumEdit.SetText(const AValue: string);
      var
        Val:  String;
      begin
        if not (csReading in ComponentState) then begin
          Val := TextToValText(AValue);
          if Val <> '' then FValue := CheckValue(StrToFloat(Val))
                       else FValue := 0;
          DataChanged;
          SkinData.Invalidate;
        end;
      end;

      But again: this stems from a TsDBCalcEdit control that’s being filled from the database. Not by the user. Why do you want to do a CheckValue in that case? What possible correction can the user make if the Min/Max message pops up? He/she is not editing the field at that time, program logic may even prohibit editing of the field!

      #69711
      HeDiBo
      Participant

        I think function TsCustomNumEdit.CheckValue should should start off like this:

        begin
          Result := NewValue;
          if not Modified then Exit;   // Accept any value if field is not entered by user
          if FMaxValue <> FMinValue then
        .
        .
        .

        That would not cure the Conversion error above, but would once and for all get rid of unmanageable data errors.

      Viewing 2 posts - 1 through 2 (of 2 total)
      • You must be logged in to reply to this topic.