Tuesday, February 14, 2006

Converting the first letter of an EditBox to uppercase

To convert the first letter of an EditBox to uppercase this code can be used:




    procedure TForm1.Edit1Change(Sender: TObject);

    var

      OldStart : Integer;

    begin

      With Edit1 do

        if Text <> '' then begin

          OnChange := NIL;

          OldStart := SelStart;

          Text := UpperCase(Copy(Text,1,1))+LowerCase(Copy(Text,2,Length(Text)));

          SelStart := OldStart;

          OnChange := Edit1Change;

        end;

    end;

0 Comments:

Post a Comment

<< Home