Giordano,
Para que o conteúdo fique alinhado, é necessário que a coluna seja criada com a classe TCColumn
.
A classe TCColumn
dá a possiblidade de informar uma picture e também o alinhamento da coluna, com isso as colunas do browse serão criadas via método addColumn
.
Veja um exemplo abaixo:
#include "totvs.ch"
//-------------------------------------------------------------------
/*/{Protheus.doc} TWBrowse
Exemplo de TWBrowse com alinhamento nas colunas
@author Daniel Mendes
@since 03/05/2022
@version 1.0
/*/
//-------------------------------------------------------------------
user function TWBrowse()
local oOK as object
local oNO as object
local oDlg as object
local oBrowse as object
local aBrowse as array
oOK := LoadBitmap(GetResources(), "br_verde")
oNO := LoadBitmap(GetResources(), "br_vermelho")
//TDialog():New( [ nTop ], [ nLeft ], [ nBottom ], [ nRight ], [ cCaption ], [ uParam6 ], [ uParam7 ], [ uParam8 ], [ uParam9 ], [ nClrText ], [ nClrBack ], [ uParam12 ], [ oWnd ], [ lPixel ], [ uParam15 ], [ uParam16 ], [ uParam17 ], [ nWidth ], [ nHeight ], [ lTransparent ] )
oDlg = TDialog():New( 180, 180, 550, 700, "Exemplo TWBrowse",,, .F.,,,,,, .T.,,,,, )
//TWBrowse(): New ( [ nRow], [ nCol], [ nWidth], [ nHeight], [ bLine], [ aHeaders], [ aColSizes], [ oDlg], [ cField], [ uValue1], [ uValue2], [ bChange], [ bLDblClick], [ bRClick], [ oFont], [ oCursor], [ nClrFore], [ nClrBack], [ cMsg], [ uParam20], [ cAlias], [ lPixel], [ bWhen], [ uParam24], [ bValid], [ lHScroll], [ lVScroll] )
oBrowse := TWBrowse():New(01, 01, 260, 184,,,, oDlg,,,,,,,,,,,, .F.,, .T.,, .F.,,,)
aBrowse := {{.T., "TESTE 1", 10, 0.60}, {.T., "TESTE 1", 20, 0.7556}, {.T., "TESTE 1", 30, 1} }
oBrowse:setArray(aBrowse)
//TCColumn():New( < cTitulo >, < bData >, [ cPicture ], [ uParam4 ], [ uParam5 ], [ cAlinhamento ], [ nLargura ], [ lBitmap ], [ lEdit ], [ uParam10 ], [ bValid ], [ uParam12 ], [ uParam13 ], [ uParam14 ] )
oBrowse:addColumn( TCColumn():New("", {||If(aBrowse[oBrowse:nAt,01],oOK,oNO)}, /*cPicture*/ ,,, "CENTER", 20, .T., .F.,,,,,) )
oBrowse:addColumn( TCColumn():New("Descrição", {||aBrowse[oBrowse:nAt,02]}, /*cPicture*/ ,,, "LEFT" , 70, .F., .F.,,,,,) )
oBrowse:addColumn( TCColumn():New("Inteiro", {||aBrowse[oBrowse:nAt,03]}, "999,999.999",,, "RIGHT" , 30, .F., .F.,,,,,) )
oBrowse:addColumn( TCColumn():New("Decimal", {||aBrowse[oBrowse:nAt,04]}, "999,999.999",,, "RIGHT" , 30, .F., .F.,,,,,) )
oBrowse:bLDblClick := {|| aBrowse[oBrowse:nAt][1] := !aBrowse[oBrowse:nAt][1], oBrowse:drawSelect() }
//Activate( [ uParam1 ], [ uParam2 ], [ uParam3 ], [ lCentered ], [ bValid ], [ uParam6 ], [ bInit ], [ uParam8 ], [ uParam9 ] )
oDlg:Activate(,,,.T.,,,,,)
return
Documentações:
https://tdn.engpro.totvs.com.br/display/tec/TWBrowse
https://tdn.engpro.totvs.com.br/display/tec/TCBrowse
https://tdn.totvs.com/display/tec/TCColumn