Delphi: Autoscale TEdit based on text length does not work when removing chars

Posted by pr0wl on Stack Overflow See other posts from Stack Overflow or by pr0wl
Published on 2010-03-28T00:45:56Z Indexed on 2010/03/28 0:53 UTC
Read the original article Hit count: 384

Filed under:
|

Hello.

I have an input edit field where the user can enter data. I want the box width to be at least 191px (min) and maximum 450px (max).

procedure THauptform.edtEingabeChange(Sender: TObject);
begin

// Scale
if Length(edtEingabe.Text) > 8 then
    begin
        if Hauptform.Width <= 450 then
            begin
                verschiebung := verschiebung + 9;
                // The initial values like 'oldedtEingabeWidth' are global vars.
                edtEingabe.Width := oldedtEingabeWidth + verschiebung;
                buDo.Left := oldbuDoLeft + verschiebung;
                Hauptform.Width := oldHauptformWidth + verschiebung;
            end;
    end;
end;

This works for ENTERING text. But when I delete one char, it does not scale back accordingly.

© Stack Overflow or respective owner

Related posts about delphi

Related posts about scale