2005. december 11., vasárnap

How to limit the number of lines in a TRichEdit


Problem/Question/Abstract:

I have a form with fixed size boxes. I want to prevent the user from overfilling it. Is it possible to limit the height or at least the number of lines in a TRichEdit?

Answer:

Try keypress code like this:

procedure Form1.FMemo1KeyPress(Sender: TObject; var Key: Char);
begin
  if (Key = #13) and ((Sender as TRichEdit).Lines.Count >= 32) then
    Key := #0;
end;

Nincsenek megjegyzések:

Megjegyzés küldése