xBrowse and datas

xBrowse and datas

Postby Wanderson » Fri Aug 13, 2010 6:16 pm

Hi i have a xbrowse like this:

oBrw := TXBrowse():New( oDlg )
oBrw:nMarqueeStyle := MARQSTYLE_HIGHLROW
oBrw:CreateFromResource( 109 )
oBrw:nColDividerStyle := 5 //LINESTYLE_BLACK // COLUNAS
oBrw:lColDividerComplete := .T.
oBrw:nHeaderHeight :=30
oBrw:nStretchCol := STRETCHCOL_LAST
oCol := oBrw:AddCol()
oCol:bStrData := { || ARQEMP->SIGLA }
oCol:cHeader := "SIGLA"
oCol := oBrw:AddCol()
oCol:bStrData := { || ARQEMP->FANTASIA }
oCol:cHeader := "FANTASIA"
oCol := oBrw:AddCol()
oCol:bStrData := { || Substr(ARQEMP->CIDADE,1,28) }
oCol:cHeader := "CIDADE"
oCol := oBrw:AddCol()
oCol:bStrData := { || ARQEMP->UF }
oCol:cHeader := "UF"

But they display just the same records in all browser area. If i put Sele ARQEMP and Set Order to 1 and Go Top before this definitions runs ok, but i use Dabase object how i set txbrowse alias with a Database object and how i link the columns? oCol:bStrData := { || oArqEmp:SIGLA } This is correct?
Thanks in advance.
Wanderson
 
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Re: xBrowse and datas

Postby James Bott » Fri Aug 13, 2010 11:12 pm

Wanderson,

...but i use Dabase object how i set txbrowse alias with a Database object and how i link the columns? oCol:bStrData := { || oArqEmp:SIGLA } This is correct?


Yes, your bStrData definition is correct. You must also tell TXBrowse that you are using a database object:

oBrw:SetoDBF( oArqEmp )

May I suggest naming your database object after the realworld object, for example "oEmployees." This makes the code easier to read and understand, especially a year from now.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: xBrowse and datas

Postby nageswaragunupudi » Fri Aug 13, 2010 11:51 pm

Please do not forget to specify the alias in the above case when you are coding for DBF.
Code: Select all  Expand view

oBrw   := TXBrowse():New( oDlg )
oBrw:cAlias := "ARQEMP"   // important
 


Instead of coding oCol := oBrw:AddCol(), oBrw:bStrData := ... for each column, it is easier and more useful to code oBrw:SetRDD( lAddCols, lAutoSort, aFieldNames )
The entire above code can be written as:
Code: Select all  Expand view

oBrw   := TXBrowse():New( oDlg )
WITH OBJECT oBrw
   // If using DBF include these two lines
   :cAlias := "ARQEMP"
   :SetRDD( .f., .t., { "SIGLA", "FANTASIA", "CIDADE", "UF" } )
   // If using TDataBase object, include the following one line and remove the above 2 lines
   :SetoDbf( oArqEmp, { "SIGLA", "FANTASIA", "CIDADE", "UF" }, .t. )
   
   // next lines are common for both
   :nColDividerStyle := LINESTYLE_BLACK
   :lColDividerComplete := .t.
   :nHeaderHeight := 30
   :nStretchCol   := STRETCHCOL_LAST
   :CreateFromResource( 109 )
END
ACTIVATE DIALOG oDlg
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10308
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: xBrowse and datas

Postby James Bott » Sat Aug 14, 2010 12:17 am

Rao,

:SetoDbf( oArqEmp, { "SIGLA", "FANTASIA", "CIDADE", "UF" }, .t. )


When using the aCols parameter, how do you define colum titles that are different than the fieldnames. I'm guessing we have to assign them to each column?

oBrw:aCols[ 2 ]:cHeader:="Whatever"

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: xBrowse and datas

Postby Wanderson » Sat Aug 14, 2010 1:31 am

Thanks James works great!
Wanderson
 
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm

Re: xBrowse and datas

Postby Wanderson » Sat Aug 14, 2010 1:36 am

nageswaragunupudi wrote:Please do not forget to specify the alias in the above case when you are coding for DBF.
Code: Select all  Expand view

oBrw   := TXBrowse():New( oDlg )
oBrw:cAlias := "ARQEMP"   // important
 


Instead of coding oCol := oBrw:AddCol(), oBrw:bStrData := ... for each column, it is easier and more useful to code oBrw:SetRDD( lAddCols, lAutoSort, aFieldNames )
The entire above code can be written as:
Code: Select all  Expand view

oBrw   := TXBrowse():New( oDlg )
WITH OBJECT oBrw
   // If using DBF include these two lines
   :cAlias := "ARQEMP"
   :SetRDD( .f., .t., { "SIGLA", "FANTASIA", "CIDADE", "UF" } )
   // If using TDataBase object, include the following one line and remove the above 2 lines
   :SetoDbf( oArqEmp, { "SIGLA", "FANTASIA", "CIDADE", "UF" }, .t. )
   
   // next lines are common for both
   :nColDividerStyle := LINESTYLE_BLACK
   :lColDividerComplete := .t.
   :nHeaderHeight := 30
   :nStretchCol   := STRETCHCOL_LAST
   :CreateFromResource( 109 )
END
ACTIVATE DIALOG oDlg
 


Thanks G. N. Rao., but in this case why i set many diferents properties of columns like pictures, colors, fonts and others? Setting one bye one column is more flexible and clear or not?
Wanderson
 
Posts: 332
Joined: Thu Nov 17, 2005 9:11 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 26 guests

cron