Page 1 of 1

I want the user cannot write more than 12 lines

Posted: Wed Mar 20, 2024 11:39 am
by armagnac
As I say in the title, I want to limit the number of lines writed by the user in a TRichViewEdit.

Maybe there are different ways :
- disable KeyPress if line count > 12
- unable the rve to scroll is user want to begin a 13th line
- other idea

Thanks

Re: I want the user cannot write more than 12 lines

Posted: Wed Mar 20, 2024 12:31 pm
by Sergey Tkachenko
There is no built-in line count limitation.
You can process OnChange event.

In this event, check line count:

Code: Select all

function IsParaCountOk(rv: TCustomRichView; MaxCount: Integer): Boolean;
var
  Count: Integer;
begin
  Result := False;
  Count := 0;
  for i := 0 ro rv.ItemCount - 1 do
    if rv.IsFromNewLine[i] then
    begin
      inc(Count);
      if Count > MaxCount then
        exit;
    end;
   Result := True;
end;
If not ok, call Undo.