Hello,
I need some help for specific TXBrowse() example.
Is there way to create txbrowse for database from array (like old dbedit function)?
*----------------------------------------------------------------------------------
use customer
aHead:={}
aField:={}
aFormt:={}
aadd( aHead,"First" ); aadd( aHead,"Second"); aadd( aHead,"Amount" )
aadd( aField,"first" ); aadd( aField,"second"); aadd( aField,"amo" )
aadd( aFormt,"@!" ); aadd( aFormt,"@!"); aadd( aFormt,"@999,999.99" )
My idea is to create txbrowse in For...Next loop using down shown example. Is it possible?
For nFor=1 to 3
oCol:= oBrw:AddCol()
oCol:bStrData := { || customer->first } //??
oCol:bEditvalue := { || customer->first } //??
oCol:cEditPicture := aFormt[nFor]
oCol:cHeader := aHead[nFor]
oCol:nEditType := 1
next
Best regards,
How to create TxBrowse in For...Next loop
How to create TxBrowse in For...Next loop
Boris (FWH 20.07, xHarbour 1.2.3, Harbour 3.2.0, BCC74, MySql 5.7)
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Very very easy.
Assume we have these arrays:
aCols // array of field names
aPics // array of picture formats
aHeaders // array of headers
@ 0,0 XBROWSE oBrw ;
COLUMNS aCols ;
PICTURES aPics ;
HEADERS aHeaders ;
OF oWnd ;
ALIAS "aliasname"
My personal advice. Avoid using old way of creating coluimns and assigning codeblocks. This requires good understanding how the xbrowse works. Command syntax is very powerful and flexible and lets us produce "bug-free" code in "few lines", in seconds rather than in minutes, easily readable and easily matintainable
By the way, only XBrowse command allows us to give the lists either as inline lists or as arrays
Assume we have these arrays:
aCols // array of field names
aPics // array of picture formats
aHeaders // array of headers
@ 0,0 XBROWSE oBrw ;
COLUMNS aCols ;
PICTURES aPics ;
HEADERS aHeaders ;
OF oWnd ;
ALIAS "aliasname"
My personal advice. Avoid using old way of creating coluimns and assigning codeblocks. This requires good understanding how the xbrowse works. Command syntax is very powerful and flexible and lets us produce "bug-free" code in "few lines", in seconds rather than in minutes, easily readable and easily matintainable
By the way, only XBrowse command allows us to give the lists either as inline lists or as arrays
Last edited by nageswaragunupudi on Tue Sep 02, 2008 10:41 pm, edited 1 time in total.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact:
Still if you want to stick to the old style of programming, here is the way
USE CUSTOMER
oBrw := TXBrows():New( oWnd ) // recommended TXBrows() not TXBrowse()
oBrw:cAlias := 'CUSTOMER' // please never never ommit this
for n := 1 to 3
CreateCol( oBrw, n, aData, aPics, aHeader )
next n
oBrw:CreateFromCode()
... etc ..
static func CreateCol( oBrw, n, aData, aPics, aHeader )
WITH OBJECT oBrw:AddCol()
:bEditValue := aData[ n ] / /aData is array of codeblocks
:cEditPicture := aPics[ n ]
:cHeader := aHeader[ n ]
END
return oCol
Note: Never create codeblocks in a loop using loop index. This is the thumb rule not only for xbrowse, but for any purpose. Use a function instead.
USE CUSTOMER
oBrw := TXBrows():New( oWnd ) // recommended TXBrows() not TXBrowse()
oBrw:cAlias := 'CUSTOMER' // please never never ommit this
for n := 1 to 3
CreateCol( oBrw, n, aData, aPics, aHeader )
next n
oBrw:CreateFromCode()
... etc ..
static func CreateCol( oBrw, n, aData, aPics, aHeader )
WITH OBJECT oBrw:AddCol()
:bEditValue := aData[ n ] / /aData is array of codeblocks
:cEditPicture := aPics[ n ]
:cHeader := aHeader[ n ]
END
return oCol
Note: Never create codeblocks in a loop using loop index. This is the thumb rule not only for xbrowse, but for any purpose. Use a function instead.
Regards
G. N. Rao.
Hyderabad, India
G. N. Rao.
Hyderabad, India
- nageswaragunupudi
- Posts: 10721
- Joined: Sun Nov 19, 2006 5:22 am
- Location: India
- Been thanked: 8 times
- Contact: