How do I know the field name in xbrowse:column

Re: How do I know the field name in xbrowse:column

Postby nageswaragunupudi » Tue Feb 01, 2022 5:04 am

In the above example, assume we want to deal with the 'Quantity' column, which is the 3rd column at the time of creation, we can find the column object in the following ways, whatever be the position at runtime and whether hidden or not:
Code: Select all  Expand view

oCol := oBrw:oCol( 3 ) --> Quantity column object, which is the 3rd column at the time of creation.
oCol := oBrw:oCol( "Quantity" ) --> Quantity column object, whose header is "Quantity"
oCol := oBrw:Quantity --> Same as above
 

Once we get the column object we want, then:
Code: Select all  Expand view

oCol:lHide --> Whether the column is hidden or not
oCol:nPos --> Visible column number at runtime if not hidden
 


Now, please explain what are you trying to do but having problems/confusion.
Regards

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

Re: How do I know the field name in xbrowse:column

Postby dutch » Tue Feb 01, 2022 8:21 am

Dear Master,

nageswaragunupudi wrote:Now, please explain what are you trying to do but having problems/confusion.


For this example
===============
Code: Select all  Expand view
COLUMNS "ITEM","UPPER(NAME)","QTY","PRICE","QTY * PRICE" ;
HEADERS "Item", "Name", "Quantity", "Rate", "Amount" ;


If I hide oBrw:aCols[1]. I need to know when I click on column #2. Is it "QTY" column?
Because when I hide column#1 and click on column#2. It shows "NAME" instead.

Thank you in advance,
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How do I know the field name in xbrowse:column

Postby Marc Venken » Tue Feb 01, 2022 11:40 am

Maybe this idea can help ...

I have a browse where I select the fields that I want to show in the originale browse.

Then I select the headers that I dont want to see anymore.
The
? obrw:ocol(3):cheader // will always stay as the started header (no changes)
but
? aNewfields[3] // The array with the new headers I want to see will give the correct header name..

So the idea is to use a second array with the fields shown. The function just retrieve the fields that have a tag to display

Image


Code: Select all  Expand view

function Reorderbrowse(oBrw)
   local aNewfields:={}
   xlsfields->(dbgotop())
   DBEVAL( { || If(   xlsfields->nouse = .F. ,AAdd( aNewfields, alltrim(xlsfields->xlsfield)),NIL) } )
   oBrw:ReArrangeCols( aNewfields )
   ? obrw:ocol(3):cheader
   ? aNewfields[3]
   oBrw:refresh()
return NIL
 
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1434
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: How do I know the field name in xbrowse:column

Postby dutch » Sun Dec 17, 2023 5:35 pm

Dear Mst.Rao and Maurizio,
I got another problem for ::nFreeze. If you scroll to right until the column hide under freeze, the :cExpr will show incorrected.
Maurizio wrote:I use

cField := oBrw:aCols[oBrw:nColSel]:cExpr

Maurizio
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How do I know the field name in xbrowse:column

Postby Maurizio » Mon Dec 18, 2023 2:13 pm

I don't know if this is correct but you can try with :nColOffSet

Code: Select all  Expand view
oBrw:bLDblClick := <||
           Local  n := oBrw:nColSel
           if oBrw:nColOffSet >  1
              n+= oBrw:nColOffSet - 1
           endif
           ? oBrw:aCols[n]:cExpr
           Return nil
         }


Maurizio
User avatar
Maurizio
 
Posts: 824
Joined: Mon Oct 10, 2005 1:29 pm

Re: How do I know the field name in xbrowse:column

Postby dutch » Mon Dec 18, 2023 3:45 pm

Dear Maurizio,

It's work correct, thanks.
Maurizio wrote:I don't know if this is correct but you can try with :nColOffSet

Code: Select all  Expand view
oBrw:bLDblClick := <||
           Local  n := oBrw:nColSel
           if oBrw:nColOffSet >  1
              n+= oBrw:nColOffSet - 1
           endif
           ? oBrw:aCols[n]:cExpr
           Return nil
         }


Maurizio
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Re: How do I know the field name in xbrowse:column

Postby nageswaragunupudi » Mon Dec 18, 2023 4:45 pm

dutch wrote:Dear Mst.Rao and Maurizio,
I got another problem for ::nFreeze. If you scroll to right until the column hide under freeze, the :cExpr will show incorrected.
Maurizio wrote:I use

cField := oBrw:aCols[oBrw:nColSel]:cExpr

Maurizio


Try
Code: Select all  Expand view
cField := oBrw:SelectedCol():cExpr
Regards

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

Re: How do I know the field name in xbrowse:column

Postby dutch » Tue Dec 19, 2023 6:20 pm

nageswaragunupudi wrote:
dutch wrote:Dear Mst.Rao and Maurizio,
I got another problem for ::nFreeze. If you scroll to right until the column hide under freeze, the :cExpr will show incorrected.
Maurizio wrote:I use

cField := oBrw:aCols[oBrw:nColSel]:cExpr

Maurizio


Dear Master,

It works correctly. Thx.

Try
Code: Select all  Expand view
cField := oBrw:SelectedCol():cExpr
Regards,
Dutch

FWH 19.01 / xHarbour Simplex 1.2.3 / BCC73 / Pelles C / UEStudio
FWPPC 10.02 / Harbour for PPC (FTDN)
ADS V.9 / MySql / MariaDB
R&R 12 Infinity / Crystal Report XI R2
(Thailand)
User avatar
dutch
 
Posts: 1542
Joined: Fri Oct 07, 2005 5:56 pm
Location: Thailand

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 81 guests