How to add cols in a xbrowse at runtime?

How to add cols in a xbrowse at runtime?

Postby vilian » 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
User avatar
vilian
 
Posts: 913
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: How to add cols in a xbrowse at runtime?

Postby Rick Lipkin » 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: Select all  Expand view


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
User avatar
Rick Lipkin
 
Posts: 2606
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: How to add cols in a xbrowse at runtime?

Postby vilian » Tue Apr 25, 2017 2:18 pm

Thank you ;)
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 913
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil

Re: How to add cols in a xbrowse at runtime?

Postby nageswaragunupudi » Wed Apr 26, 2017 12:06 pm

From 17.04 onwards you can also use:
Code: Select all  Expand view

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
User avatar
nageswaragunupudi
 
Posts: 10206
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: How to add cols in a xbrowse at runtime?

Postby vilian » Wed Apr 26, 2017 8:05 pm

Thanks Mr Rao ;)
Sds,
Vilian F. Arraes
vilian@vfatec.com.br
Belém-Pa-Brazil
User avatar
vilian
 
Posts: 913
Joined: Wed Nov 09, 2005 2:17 am
Location: Brazil


Return to FiveWin for Harbour/xHarbour

Who is online

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