Usina BRAdvPL Guide
Sign in
← All topics
COMMANDPublished

@ ... BROWSE

@ <nRow>, <nCol> [COLUMN] BROWSE <oBrw> [FIELDS <campos>] [ALIAS <cAlias>] [SIZE <nWidth>, <nHeight>] [OF <oDlg>] [PIXEL]

Creates a TCBrowse component for navigating and displaying table or array data.

Visual interfaceBrowseTCBrowseTablesArraysCommands
01 · OVERVIEW

Overview

The @ ... BROWSE command creates a visual navigation grid and stores the resulting object in an AdvPL variable. During compilation, its syntax is translated into the TCBrowse class New() constructor. The component may receive table fields and an alias directly, or be created empty, associated with an array through SetArray(), and populated with columns later.

02 · SYNTAX

Syntax

@ <nRow>, <nCol> [COLUMN] BROWSE <oBrw> [FIELDS <campos>] [ALIAS <cAlias>] [SIZE <nWidth>, <nHeight>] [OF <oDlg>] [PIXEL]

Parameters

nRow, nCol
NuméricoRequired

Row and column where the browse is placed. With PIXEL, coordinates start at the upper-left corner of the parent.

oBrw
ObjetoRequired

Variable that receives the created TCBrowse object.

FIELDS campos
CaractereOptional

Table fields that form the columns. The FIELDS keyword is optional but improves clarity.

ALIAS cAlias
CaractereOptional

Alias of the table used by the component.

FIELDSIZES / SIZES / COLSIZES
NuméricoOptional

Widths of automatically created columns, in field order.

HEAD / HEADER / HEADERS
CaractereOptional

Titles of automatically created columns, in field order.

SIZE nWidth, nHeight
NuméricoOptional

Component width and height.

OF oDlg
ObjetoOptional

Dialog, panel, folder or other visual container that owns the browse. OF is recommended by the official documentation.

SELECT cField FOR uValue1 [TO uValue2]
FiltroOptional

Defines a value or range filter for a field when a table is used.

ON CHANGE / ON DBLCLICK / ON RIGHT CLICK
EventoOptional

Actions run on row change, double-click or right-click.

FONT · CURSOR · COLOR · MESSAGE · PIXEL · WHEN · VALID
CláusulasOptional

Customize font, cursor, colors, hint, coordinates, focus acceptance and validation.

03 · PRACTICAL EXAMPLE

Array-based browse

#Include "TOTVS.ch"
#Include "tcbrowse.ch"

User Function ExBrowseArray()
    Local oDlg
    Local oBrowse
    Local aCustomers := { ;
        {"000001", "Alpha Customer", 1500.00}, ;
        {"000002", "Beta Customer", 2750.50}  ;
    }

    Define Dialog oDlg Title "Customers" ;
        From 180, 180 To 600, 650 Pixel

    @ 1, 1 Browse oBrowse Size 220, 156 Of oDlg Pixel
    oBrowse:SetArray(aCustomers)

    Add Column To oBrowse Array Element 1 Header "Code" Size 60
    Add Column To oBrowse Array Element 2 Header "Name" Size 110
    Add Column To oBrowse Array Element 3 Header "Amount" Size 70

    Activate Dialog oDlg Centered
Return
Expected result

SetArray() associates the data and each ADD COLUMN selects the array element to display.

04 · PRACTICAL EXAMPLE

Browse connected to a table

#Include "TOTVS.ch"
#Include "tcbrowse.ch"

User Function ExBrowseTabela()
    Local oDlg
    Local oBrowse

    DbSelectArea("SA1")
    SA1->(DbGoTop())

    Define Dialog oDlg Title "Cadastro de clientes" ;
        From 0, 0 To 300, 600 Pixel

    @ 10, 10 Browse oBrowse ;
        Fields SA1->A1_COD, SA1->A1_NOME ;
        Alias "SA1" ;
        Headers "Código", "Nome" ;
        ColSizes 60, 180 ;
        Size 270, 120 Of oDlg Pixel

    Activate Dialog oDlg Centered
Return
Expected result

The alias supplies records while FIELDS, HEADERS and COLSIZES define automatic columns.

BEST PRACTICES
  • Include tcbrowse.ch; dialog examples also commonly include TOTVS.ch.
  • For tables, FIELDS, HEADERS and COLSIZES can create columns automatically.
  • For arrays, create the browse, call SetArray(), and add columns with ADD COLUMN TO ... ARRAY ELEMENT or TCColumn and AddColumn().
  • Prefer OF to explicitly identify the owner container.
  • Keep field, header and size lists aligned in count and order.
  • Use GoUp(), GoDown(), GoTop() and GoBottom() for programmatic navigation.
COMMON PITFALLS
  • An array-based browse does not receive data from its declaration alone; call SetArray().
  • Mismatched FIELDS, HEADERS and COLSIZES lists create incorrect columns.
  • Without OF, the component is bound to the active window or dialog.
  • Mixing PIXEL coordinates with another unit may position or size the browse incorrectly.
  • Large event expressions are hard to maintain; delegate to a dedicated function.
  • TCBrowse is a historical visual component; confirm its execution context and consider FWBrowse or FWMBrowse when the framework is more appropriate.

Related content

REFERENCES
  1. TOTVS. @ ... BROWSE. TDN. Created by Julio Wittwer on May 31, 2019.
  2. TOTVS. TCBrowse:New — constructor used by the command. TDN.
  3. eADVPL Reference Guide. No author identified, created July 28, 2005. Related section: p. 16–17. Historical reference; syntax checked primarily against a current source.
Status
Published
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR