RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TBoundLabel.Top Property

Specifies the Y coordinate of the top left corner of a control, relative to its parent or containing control in pixels.

Pascal
property Top: Integer;
C++
__property int Top;

Use Top to locate the top of the control or reposition the control to a different Y coordinate. The Top property, like the Left property, is the position of the control relative to its container. Thus, if a control is contained in a TPanel, the Left and Top properties are relative to the panel. If the control is contained directly by the form, it is relative to the form. For forms, the value of the Top property is relative to the screen in pixels.  

C++ Examples: 

 

/*
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 or is clicked, the controls within 
the group box are moved in the appropriate direction.
*/
void __fastcall TForm1::UpDown1Click(TObject *Sender, TUDBtnType Button)
{
  int I;
  TControl *ChildControl;

  for (I = 0; I < GroupBox1->ControlCount; I++)
  {
    ChildControl = GroupBox1->Controls[I];
    if (Button == btNext) 
      ChildControl->Top = ChildControl->Top + 15;
    else
      ChildControl->Top = ChildControl->Top - 15;
  }
}

void __fastcall TForm1::FormCreate(TObject *Sender)
{
  const TColor colorarray[5] = {clYellow, clGreen, clBlue, clLime, clFuchsia};
  GroupBox1->Brush->Color = clRed;
  for (int i = 0; i < GroupBox1->ControlCount; i++)
    ((TWinControl *)GroupBox1->Controls[i])->Brush->Color = colorarray[i];
}

 

Delphi Examples: 

{
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 or is clicked, the controls within 
the group box are moved in the appropriate direction.
}
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;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!