FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How to add cols in a xbrowse at runtime?
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
How to add cols in a xbrowse at runtime?
Posted: Tue Apr 25, 2017 11:50 AM

Hi Guys,

I'm doing a xbrowse of a rowset and I need to add cols at runtime. Could someone help me ?

Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: How to add cols in a xbrowse at runtime?
Posted: Tue Apr 25, 2017 12:52 PM
Vilian

Here is the code I use .. I think Rao may have a better solution ... however, this is will work... I am inserting\adding a Customer name at column 2:


Code (fw): Select all Collapse
ADD oCol TO oLbx AT 2 DATA {|x| x := If(oRsRepair:Eof, ,_ChkCust(oRsRepair:Fields("lname"):Value,;
                   oRsRepair:Fields("fname"):Value))  } HEADER "Customer Name" size 150 ;
                             SORT "LNAME"

.
.
.

//-------------------
Static Func _ChkCust( cLast,cFirst )

Local cName

If cFirst = " " .or. empty( cFirst)
   cName := substr(alltrim( cLast )+space(40),1,40)
Else
   cName := substr(alltrim( cLast )+", "+alltrim(cFirst)+space(40),1,40)
Endif

Return(cName)


Rick Lipkin
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: How to add cols in a xbrowse at runtime?
Posted: Tue Apr 25, 2017 02:18 PM

Thank you ;)

Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: How to add cols in a xbrowse at runtime?
Posted: Wed Apr 26, 2017 12:06 PM
From 17.04 onwards you can also use:
Code (fw): Select all Collapse
oCol := oRs:XbrAddColumn( oBrw, cFieldName, [cHeader] )
WITH OBJECT oCol
   // other clauses
END

Using this method, the new column is fully configured including width, picture clause, alignment, etc.
Regards



G. N. Rao.

Hyderabad, India
Posts: 1067
Joined: Wed Nov 09, 2005 02:17 AM
Re: How to add cols in a xbrowse at runtime?
Posted: Wed Apr 26, 2017 08:05 PM

Thanks Mr Rao ;)

Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil

Continue the discussion