FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour xBrowse and datas
Posts: 332
Joined: Thu Nov 17, 2005 09:11 PM
xBrowse and datas
Posted: Fri Aug 13, 2010 06: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.

Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: xBrowse and datas
Posted: 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
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: xBrowse and datas
Posted: 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 (fw): Select all Collapse
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 (fw): Select all Collapse
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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: xBrowse and datas
Posted: 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 ]:="Whatever"

Regards,
James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 332
Joined: Thu Nov 17, 2005 09:11 PM
Re: xBrowse and datas
Posted: Sat Aug 14, 2010 01:31 AM

Thanks James works great!

Posts: 332
Joined: Thu Nov 17, 2005 09:11 PM
Re: xBrowse and datas
Posted: Sat Aug 14, 2010 01:36 AM
nageswaragunupudi wrote:Please do not forget to specify the alias in the above case when you are coding for DBF.
Code (fw): Select all Collapse
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 (fw): Select all Collapse
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?

Continue the discussion