HideScrollBars (Delphi)
Description
This example requires: TRichEdit, TRadioGroup, TCheckBox, and TButton. Clicking the Radio Group control sets the ScrollBar style of the RichEdit. Toggling the Check Box turns HideScrollBars on and off. Clicking the button loads the Rich Edit with a large amount of contiguous text.
Code
procedure TForm1.Button1Click(Sender: TObject);
var
I: Integer;
begin
RichEdit1.Lines.Clear;
for I := 0 to 500 do
begin
RichEdit1.Text :=
RichEdit1.Text + 'test line ' + IntToStr(I) + ' ';
if (i mod 4 = 0) then
RichEdit1.Text := RichEdit1.Text + Chr(13);
end;
// Move caret to the top of the edit box.
RichEdit1.SelStart := 0;
end;
procedure TForm1.CheckBox1Click(Sender: TObject);
begin
RichEdit1.HideScrollbars := CheckBox1.Checked;
end;
procedure TForm1.RadioGroup1Click(Sender: TObject);
const
ScrollBarA: array[0..3] of TScrollStyle = (
ssBoth,
ssHorizontal,
ssNone,
ssVertical);
begin
RichEdit1.ScrollBars :=
ScrollBarA[RadioGroup1.ItemIndex];
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
with RadioGroup1, Items do
begin
Caption := 'Scroll Bars';
Clear;
Add('ssBoth');
Add('ssHorizontal');
Add('ssNone');
Add('ssVertical');
end;
with CheckBox1 do
begin
Caption := 'HideScrollBars';
Checked := True;
end;
Button1.Caption := 'Loaded';
RichEdit1.Text := 'Just a little text.';
RichEdit1.WordWrap := False;
end;
Uses
- Vcl.ComCtrls.TCustomRichEdit.HideScrollBars ( fr | de | ja )
- Vcl.StdCtrls.TCustomMemo.ScrollBars ( fr | de | ja )
- Vcl.StdCtrls.TCustomMemo.WordWrap ( fr | de | ja )
- System.Chr ( fr | de | ja )