Difference between revisions of "TSplitter/de"
(Created page with "{{TSplitter}} <br> Ein vertikaler oder horizontaler Balken auf einem Panel oder Formular platziert, um Unterpanel funktionell zu trennen <br> =TSplitter= Die LCL Komponente ...") |
|||
Line 9: | Line 9: | ||
Es ist in der Unit '''ExtCtrls''' definiert und befindet sich auf der IDE Komponentenpalette ''Additional''. | Es ist in der Unit '''ExtCtrls''' definiert und befindet sich auf der IDE Komponentenpalette ''Additional''. | ||
− | TSplitter kann grundsätzlich in zwei verschiedenen Modi arbeiten: über Align (ausrichten - analog Delphi) oder über AnchorSides (nicht von Delphi unterstützt). | + | TSplitter kann grundsätzlich in zwei verschiedenen Modi arbeiten: über [[Autosize_/_Layout#Align|Align]] (ausrichten - analog Delphi) oder über [[Autosize_/_Layout#Anchor_Sides|AnchorSides]](nicht von Delphi unterstützt). |
=Splitter und Align= | =Splitter und Align= |
Revision as of 09:08, 12 May 2014
│
Deutsch (de) │
English (en) │
suomi (fi) │
français (fr) │
русский (ru) │
Ein vertikaler oder horizontaler Balken auf einem Panel oder Formular platziert, um Unterpanel funktionell zu trennen
TSplitter
Die LCL Komponente TSplitter kann als visuelle Trennlinie zwischen zwei Hälften des Formulars verwendet werden und ermöglicht dem Benutzer diese entweder vertikal oder horizontal zu bewegen. Es ist in der Unit ExtCtrls definiert und befindet sich auf der IDE Komponentenpalette Additional.
TSplitter kann grundsätzlich in zwei verschiedenen Modi arbeiten: über Align (ausrichten - analog Delphi) oder über AnchorSides(nicht von Delphi unterstützt).
Splitter und Align
Align can be used for many simple layouts like two controls or a row of controls. For example when you need some freely resizable controls like a memo and a listbox.
The following example demonstrates this.
In Form designer
- create a new form
- drop a TMemo on a form (left click on the TMemo icon in component paletter to select, then left click on the form)
- set in Object Inspector Align of Memo1 to alLeft.
- drop a TSplitter on a form
- the default Align is already alLeft
- drop another TMemo on the form.
- set in Object Inspector Align of Memo2 to alClient.
As lfm
object Memo1: TMemo
Left = 0
Height = 141
Top = 0
Width = 150
Align = alLeft
Lines.Strings = (
'Memo1'
)
TabOrder = 0
end
object Splitter1: TSplitter
Left = 150
Height = 141
Top = 0
Width = 5
end
object Memo2: TMemo
Left = 155
Height = 141
Top = 0
Width = 100
Align = alClient
Lines.Strings = (
'Memo2'
)
TabOrder = 2
end
The same in code
procedure TMainForm.FormCreate(Sender: TObject);
var
Memo1: TMemo;
Splitter1: TSplitter;
Memo2: TMemo;
begin
Memo1:=TMemo.Create(Self);
with Memo1 do begin
Name:='Memo1';
Parent:=Self;
Align:=alLeft;
end;
Splitter1:=TSplitter.Create(Self);
with Splitter1 do begin
Name:='Splitter1';
Parent:=Self;
Left:=1; // position it right of Memo1
Align:=alLeft;
end;
Memo2:=TMemo.Create(Self);
with Memo2 do begin
Name:='Memo2';
Parent:=Self;
Align:=alClient;
end;
end;
Splitter mit AnchorSides
Anchor sides allows more fine tuned layouts. Align fills all the space. AnchorSides allow to anchor controls to any other sibling control.
Example in IDE designer
- create a new form
- drop a TMemo on a form (left click on the TMemo icon in component paletter to select, then left click on the form)
- set in Object Inspector Align of Memo1 to alLeft
- drop a TSplitter on a form
- set the Align property of the Splitter1 to alNone
- select the Memo1
- View -> Anchor Editor
- anchor the right side of Memo1 to the Splitter1
- drop another TMemo on the form.
- set the Align property of Memo2 to alRight.
- anchor the left side of Memo2 to Splitter1. Make sure to anchor to the right side of Splitter1 (the button on the Anchor editor below the combobox).
In lfm
The same as lfm:
object Memo1: TMemo
AnchorSideRight.Control = Splitter1
Left = 0
Height = 141
Top = 0
Width = 145
Align = alLeft
Anchors = [akTop, akLeft, akRight, akBottom]
Lines.Strings = (
'Memo1'
)
TabOrder = 0
end
object Splitter1: TSplitter
Left = 145
Height = 141
Top = 0
Width = 5
Align = alNone
end
object Memo2: TMemo
AnchorSideLeft.Control = Splitter1
AnchorSideLeft.Side = asrBottom
Left = 150
Height = 141
Top = 0
Width = 105
Align = alRight
Anchors = [akTop, akLeft, akRight, akBottom]
Lines.Strings = (
'Memo2'
)
TabOrder = 2
end
In code
The same in code:
procedure TMainForm.FormCreate(Sender: TObject);
var
Memo1: TMemo;
Splitter1: TSplitter;
Memo2: TMemo;
begin
Memo1:=TMemo.Create(Self);
with Memo1 do begin
Name:='Memo1';
Parent:=Self;
Align:=alLeft;
end;
Splitter1:=TSplitter.Create(Self);
with Splitter1 do begin
Name:='Splitter1';
Parent:=Self;
Align:=alNone;
Left:=100; // some value
AnchorParallel(akBottom,0,Parent);
end;
Memo1.AnchorToNeighbour(akRight,0,Splitter1);
Memo2:=TMemo.Create(Self);
with Memo2 do begin
Name:='Memo2';
Parent:=Self;
Align:=alRight;
AnchorToNeighbour(akLeft,0,Splitter1);
end;
end;