Condividi tramite


ActiveRow Property

Specifies the row that contains the active cell in a Grid control. Not available at design time; read-only at run time.

Grid.ActiveRow

Remarks

Applies To: Grid Control

The ActiveRow property does not return the same value as RECNO( ) in an indexed table. ActiveRow returns zero if the grid doesn't have the focus or when you access a row outside the grid display.

Example

The following example creates a table and a form with a grid. The grid's ActiveRow property is used to show a row number within the grid.

CREATE TABLE ardemo (fruit C(15))
INSERT INTO ardemo (fruit) VALUES ("Apples")
INSERT INTO ardemo (fruit) VALUES ("Oranges")
INSERT INTO ardemo (fruit) VALUES ("Grapes")
INSERT INTO ardemo (fruit) VALUES ("Bananas")
INSERT INTO ardemo (fruit) VALUES ("Pears")
INSERT INTO ardemo (fruit) VALUES ("Cherries")
LOCATE  && Moves to top of table, synonymous with GO TOP

oForm1=NEWOBJECT("form1")
oForm1.Show
READ EVENTS
RETURN

DEFINE CLASS form1 AS Form
    Caption = "Form1"
    Name = "Form1"
    ADD OBJECT Grid1 AS Grid WITH ;
        ColumnCount = 2, ;
        Height = 200, ;
        Left = 24, ;
        RecordSource = "ardemo", ;
        Top = 24, ;
        Width = 320, ;
        Name = "Grid1", ;
        Column1.ControlSource = "ardemo.fruit", ;
        Column1.Width = 75, ;
        Column1.Name = "Column1", ;
        Column2.Bound = .F., ;
        Column2.ControlSource = "This.ActiveRow", ;
        Column2.Name = "Column2"

    PROCEDURE Init
    THIS.Grid1.Column2.Header1.Caption = 'ActiveRow'
ENDPROC
    PROCEDURE Unload
    CLEAR EVENTS
ENDPROC

ENDDEFINE

See Also

Reference

ActivateCell Method

ActiveColumn Property

GridHitTest Method

RECNO( ) Function

Other Resources

Properties (Visual FoxPro)

Language Reference (Visual FoxPro)