Share via


Top (Propiedad)

Especifica la distancia entre el borde superior de un control o de un formulario y su objeto contenedor. Está disponible en tiempo de diseño y en tiempo de ejecución.

Object.Top[ = nValue]

Valores de la propiedad

  • nValue
    Especifica la distancia entre el borde superior de un objeto y el borde superior de su objeto contenedor.

    El contenedor predeterminado para un formulario es la ventana principal de Visual FoxPro.

Observaciones

La propiedad Top especifica la distancia a la que está ubicado el objeto, respecto a su posición cero. Por ejemplo, si hay un formulario en la ventana principal de Visual FoxPro, la posición cero se encontrará justo debajo del menú del sistema o bien, si hay una barra de herramientas acoplada en la parte superior de la ventana principal, inmediatamente debajo de la barra de herramientas.

Utilice las propiedades Left y Top, y Height y Width para operaciones basadas en las dimensiones externas de un objeto, como su movimiento o ajuste de tamaño.

Nota   La propiedad Top es de sólo lectura cuando se aplica a un control contenido en un objeto Column.

La unidad de medida que utiliza la propiedad Top se determina mediante la configuración de la propiedad ScaleMode del control.

Ejemplo

El ejemplo siguiente muestra cómo se utiliza la propiedad Top para colocar controles en un formulario. El método AddObject se utiliza para agregar un control Line y tres botones de comando a un formulario. La propiedad Top especifica la colocación vertical de cada control en el formulario.

frmMyForm = CREATEOBJECT('Form')  && Create a Form
frmMyForm.Closable = .F.  && Disable the window pop-up menu

frmMyForm.AddObject('shpLine','Line')  && Add a Line control to the form
frmMyForm.AddObject('cmdCmndBtn1','cmdMyCmndBtn1')  && Up Cmnd button
frmMyForm.AddObject('cmdCmndBtn2','cmdMyCmndBtn2')  && Down Cmnd button
frmMyForm.AddObject('cmdCmndBtn3','cmdMyCmndBtn3')  && Quit Cmnd button

frmMyForm.shpLine.Visible = .T.  && Make Line control visible
frmMyForm.shpLine.Top = 20  && Specify Line control row
frmMyForm.shpLine.Left = 125  && Specify Line control column

frmMyForm.cmdCmndBtn1.Visible =.T.  && Up Command button visible
frmMyForm.cmdCmndBtn2.Visible =.T.  && Down" Command button visible
frmMyForm.cmdCmndBtn3.Visible =.T.  && Quit Command button visible

frmMyForm.SHOW  && Display the form
READ EVENTS  && Start event processing

DEFINE CLASS cmdMyCmndBtn1 AS COMMANDBUTTON  && Create Command button
   Caption = 'Slant \<Up'  && Caption on the Command button
   Left = 50  && Command button column
   Top = 100  && Command button row
   Height = 25  && Command button height
   
   PROCEDURE Click
      ThisForm.shpLine.Visible = .F.  && Hide the Line control
      ThisForm.shpLine.LineSlant ='/'  && Slant up
      ThisForm.shpLine.Visible = .T.  && Show the Line control
ENDDEFINE

DEFINE CLASS cmdMyCmndBtn2 AS CommandButton  && Create Command button
   Caption = 'Slant \<Down'  && Caption on the Command button
   Left = 200  && Command button column
   Top = 100  && Command button row
   Height = 25  && Command button height

   PROCEDURE Click
      ThisForm.shpLine.Visible = .F.  && Hide the Line control
      ThisForm.shpLine.LineSlant ='\'  && Slant down
      ThisForm.shpLine.Visible = .T.  && Show the Line control
ENDDEFINE

DEFINE CLASS cmdMyCmndBtn3 AS CommandButton  && Create Command button
   Caption = '\<Quit'  && Caption on the Command button
   Cancel = .T.  && Default Cancel Command button (Esc)
   Left = 125  && Command button column
   Top = 150  && Command button row
   Height = 25  && Command button height

   PROCEDURE Click
      CLEAR EVENTS  && Stop event processing, close Form
ENDDEFINE

Vea también

Left (Propiedad) | Height (Propiedad) | Move (Método) | ScaleMode (Propiedad) | Width (Propiedad)

Se aplica a: CheckBox | ComboBox | CommandButton | CommandGroup | Container (Objeto) | Control (Objeto) | Custom | EditBox | Form | Grid | Image | Label | Line | ListBox | OLE Bound (Control) | OLE Container (Control) | OptionButton | OptionGroup | PageFrame | _SCREEN | Shape | Spinner | TextBox | Timer | ToolBar