nTopTop coordinate of the component inside the visual container.
AdvPL GuideTCBrowse():New( <nTop>, <nLeft>, <nBottom>, <nRight>, <oWnd>, ... ) --> oBrowseVisual class used to display and navigate data in a grid/browse format.
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.
TCBrowse():New( <nTop>, <nLeft>, <nBottom>, <nRight>, <oWnd>, ... ) --> oBrowsenTopTop coordinate of the component inside the visual container.
nLeftLeft coordinate of the component inside the visual container.
nBottomBottom coordinate of the component.
nRightRight coordinate of the component.
oWndWindow, dialog, panel or folder where the browse is displayed.
cAliasData-area alias when the browse is table-based.
TCBrowse():New( <nTop>, <nLeft>, <nBottom>, <nRight>, <oWnd>, ... ) --> oBrowsenTopNuméricoRequiredTop position.
In PIXEL examples, read it as a pixel coordinate.
nLeftNuméricoRequiredLeft position.
Must match the unit used by the container.
nBottomNuméricoRequiredBottom position.
Helps define the component height.
nRightNuméricoRequiredRight position.
Helps define the component width.
oWndObjetoOptionalOwner visual container.
Explicitly passing the container avoids binding to the wrong active dialog.
Created TCBrowse object.
oBrowse:SetArray( <aDados> ) --> NILaDadosArrayRequiredArray containing the rows to display.
Each row is usually another array, with one position for each column.
oBrowse:AddColumn( <oColumn> ) --> NILoColumnObjetoRequiredObject describing the column title, value and properties.
Columns are also commonly added with command syntax such as ADD COLUMN TO ... ARRAY ELEMENT.
oBrowse:GoTop() --> NILoBrowse:GoBottom() --> NILoBrowse:GoUp() --> NILoBrowse:GoDown() --> NILoBrowse:Refresh() --> NILRetorna um objeto TCBrowse quando criado por New() ou por @ ... BROWSE.
#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
ReturnCreates 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.
© 2026 Usina.BR. All rights reserved. TOTVS, Protheus, Microsiga and their respective logos are trademarks of their owners. AdvPL Guide is independent and uses limited, attributed excerpts justified by educational purposes. See the Terms of Use. Terms of Use
Comments
There are no approved comments yet.
Sign in with Google or Microsoft to comment.