我的cxmemo限制为150个字符(maxlenght)。 我想使用cxProgressBar直观地表示这个限制。 我怎样才能做到这一点 ? 我试过了:
procedure TMain_Form.cxMemo1PropertiesChange(Sender: TObject);
begin
if not (trim(cxmemo1.lines.Text) = '') then begin
cxProgressBar1.Position := cxProgressBar1.Position +cxmemo1.Properties.MaxLength - Length(cxmemo1.Text);
end;
end;
但它不起作用...... 我希望当用户键入时缩小进度条,如果他正在删除备忘录中的字符,则缩小。 我怎样才能做到这一点?
答案 0 :(得分:0)
procedure TMain_Form.cxMemo1PropertiesChange(Sender: TObject);
begin
if Trim(cxMemo1.Lines.Text) <> '' then begin
cxProgressBar1.Visible := True;
cxProgressBar1.Position := Length(cxMemo1.Text);
if Length(cxMemo1.Text) = cxMemo1.Properties.MaxLength then
ShowMessage('You exceeded the maximum number of characters !' + #13#10 +'Limit is : 150 '+ #13#10 +'For more, use the field "memo" .');
end else begin
if cxMemo1.Lines.Text.IsEmpty then
cxProgressBar1.Position := 0;
cxProgressBar1.Visible := False;
end;
end;