TControlTop (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This example uses an UpDown control and a group box on a form, with several controls contained within the group box. When the UpDown control is clicked, the controls within the group box are moved in the appropriate direction.

Code

procedure TForm1.FormCreate(Sender: TObject);
var
  I: Integer;
const
  colorarray : Array[0..4] of TColor = (clYellow, clGreen, clBlue, clLime, clFuchsia);
begin
   GroupBox1.Brush.Color := clRed;
  for I:= 0 to GroupBox1.ControlCount -1 do
  begin
    TWinControl(GroupBox1.Controls[I]).Brush.Color := colorarray[I];
  end;
end;

procedure TForm1.UpDown1Click(Sender: TObject; Button: TUDBtnType);
var
  I: Integer;
  ChildControl: TControl;
begin
  for I:= 0 to GroupBox1.ControlCount -1 do
  begin
    ChildControl := GroupBox1.Controls[I];
    if Button = btNext then
      ChildControl.Top := ChildControl.Top + 15
    else
      ChildControl.Top := ChildControl.Top - 15;
  end;
end;

Uses