Usina BRAdvPL Guide
Sign in
← All topics
CLASSPublished

TCBrowse

TCBrowse():New( <nTop>, <nLeft>, <nBottom>, <nRight>, <oWnd>, ... ) --> oBrowse

Visual class used to display and navigate data in a grid/browse format.

Visual interfaceClassBrowseGridTablesArrays
01 · OVERVIEW

Overview

TCBrowse is a visual class for presenting information in rows and columns, usually inside dialogs, panels or other SmartClient windows. It may be created directly with New() or indirectly through the @ ... BROWSE command, which is a more readable way to instantiate and configure the component. The browse may work with table aliases or arrays, as long as data and columns are properly associated.

02 · SYNTAX

Syntax

TCBrowse():New( <nTop>, <nLeft>, <nBottom>, <nRight>, <oWnd>, ... ) --> oBrowse

Parameters

nTop
NuméricoRequired

Top coordinate of the component inside the visual container.

nLeft
NuméricoRequired

Left coordinate of the component inside the visual container.

nBottom
NuméricoRequired

Bottom coordinate of the component.

nRight
NuméricoRequired

Right coordinate of the component.

oWnd
ObjetoOptional

Window, dialog, panel or folder where the browse is displayed.

cAlias
CaractereOptional

Data-area alias when the browse is table-based.

Methods

NewCreates a browse instance inside a visual container.TCBrowse():New( <nTop>, <nLeft>, <nBottom>, <nRight>, <oWnd>, ... ) --> oBrowse
Parameters
NameFormatRequiredDescriptionNotes
nTopNuméricoRequired

Top position.

In PIXEL examples, read it as a pixel coordinate.

nLeftNuméricoRequired

Left position.

Must match the unit used by the container.

nBottomNuméricoRequired

Bottom position.

Helps define the component height.

nRightNuméricoRequired

Right position.

Helps define the component width.

oWndObjetoOptional

Owner visual container.

Explicitly passing the container avoids binding to the wrong active dialog.

Return value

Created TCBrowse object.

SetArrayAssociates an array with the browse for row-by-row navigation.oBrowse:SetArray( <aDados> ) --> NIL
Parameters
NameFormatRequiredDescriptionNotes
aDadosArrayRequired

Array containing the rows to display.

Each row is usually another array, with one position for each column.

AddColumnAdds a column to the browse through a column object such as TCColumn.oBrowse:AddColumn( <oColumn> ) --> NIL
Parameters
NameFormatRequiredDescriptionNotes
oColumnObjetoRequired

Object describing the column title, value and properties.

Columns are also commonly added with command syntax such as ADD COLUMN TO ... ARRAY ELEMENT.

GoTopMoves navigation to the first available row.oBrowse:GoTop() --> NIL
GoBottomMoves navigation to the last available row.oBrowse:GoBottom() --> NIL
GoUpMoves the selection one row up.oBrowse:GoUp() --> NIL
GoDownMoves the selection one row down.oBrowse:GoDown() --> NIL
RefreshRequests a visual refresh after data or configuration changes.oBrowse:Refresh() --> NIL

Return value

Retorna um objeto TCBrowse quando criado por New() ou por @ ... BROWSE.

03 · PRACTICAL EXAMPLE

TCBrowse with bLine, events and navigation

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

User Function TCBrowse()
    Local oDlg
    Local oBrowse
    Local oOK := LoadBitmap(GetResources(), "br_verde")
    Local oNO := LoadBitmap(GetResources(), "br_vermelho")
    Local aBrowse := {}

    DEFINE DIALOG oDlg TITLE "TCBrowse example" ;
        FROM 180, 180 TO 550, 700 PIXEL

    // Vector with browse rows
    aBrowse := { ;
        {.T., "CUSTOMER 001", "CUSTOMER STREET 001", 111.11}, ;
        {.F., "CUSTOMER 002", "CUSTOMER STREET 002", 222.22}, ;
        {.T., "CUSTOMER 003", "CUSTOMER STREET 003", 333.33}  ;
    }

    // Creates the browse
    oBrowse := TCBrowse():New(01, 01, 260, 156, , ;
        {"", "Code", "Name", "Amount"}, ;
        {20, 50, 90, 70}, oDlg, , , , , {||}, , , , , , , .F., , .T., , .F., , , )

    // Assigns the array to the browse
    oBrowse:SetArray(aBrowse)

    // Builds the line displayed in the browse
    oBrowse:bLine := {|| { ;
        If(aBrowse[oBrowse:nAt, 01], oOK, oNO), ;
        aBrowse[oBrowse:nAt, 02], ;
        aBrowse[oBrowse:nAt, 03], ;
        Transform(aBrowse[oBrowse:nAt, 04], "@E 99,999,999,999.99") } }

    // Browse header click event
    oBrowse:bHeaderClick := {|o, nCol| Alert("bHeaderClick") }

    // Cell double-click event
    oBrowse:bLDblClick := {|| Alert("bLDblClick") }

    // Creates buttons with basic methods
    TButton():New(160, 002, "GoUp()", oDlg, {|| oBrowse:GoUp(), oBrowse:SetFocus() }, 40, 010)
    TButton():New(160, 052, "GoDown()", oDlg, {|| oBrowse:GoDown(), oBrowse:SetFocus() }, 40, 010)
    TButton():New(160, 102, "GoTop()", oDlg, {|| oBrowse:GoTop(), oBrowse:SetFocus() }, 40, 010)
    TButton():New(160, 152, "GoBottom()", oDlg, {|| oBrowse:GoBottom(), oBrowse:SetFocus() }, 40, 010)
    TButton():New(172, 002, "Current row", oDlg, {|| Alert(oBrowse:nAt) }, 40, 010)
    TButton():New(172, 052, "Rows", oDlg, {|| Alert(oBrowse:nLen) }, 40, 010)
    TButton():New(172, 102, "Visible rows", oDlg, {|| Alert(oBrowse:nRowCount()) }, 40, 010)
    TButton():New(172, 152, "Alias", oDlg, {|| Alert(oBrowse:cAlias) }, 40, 010)

    ACTIVATE DIALOG oDlg CENTERED
Return
Expected result

Creates a browse with an array, visual row indicator, custom line rendering through bLine, header and double-click events, plus buttons that call basic navigation methods.

BEST PRACTICES
  • Use @ ... BROWSE when you want a more readable declaration and keep TCBrowse as the reference for the class created behind the command.
  • For array data, call SetArray() before expecting consistent navigation or display.
  • Declare columns explicitly to improve maintenance and readability.
  • Use variable names and titles in the language of the page when the example is educational.
  • Confirm behavior in the SmartClient and release in use, especially in legacy screens.
COMMON PITFALLS
  • Creating the browse without associated data or columns leaves an empty visual area.
  • Mixing PIXEL coordinates with non-pixel coordinates may cause misalignment.
  • Long events and code blocks inside the screen are hard to maintain.
  • TCBrowse is useful for reference and legacy maintenance, but new projects may prefer framework components such as FWBrowse or FWMBrowse.

Related content

REFERENCES
  1. TOTVS. TCBrowse. TOTVSTEC / TDN. Visual browse class reference.
  2. TOTVS. @ ... BROWSE. TOTVSTEC / TDN. Command that instantiates and configures TCBrowse.
  3. TOTVS. TCBrowse:New. TOTVSTEC / TDN. Class constructor.
Status
Published
Page created on
Last reviewed on
Original language
Portuguese
Reviewed by
Usina.BR
0 approved comment(s)

Comments

There are no approved comments yet.

Sign in with Google or Microsoft to comment.

Powered by Usina Docs · Alpha