FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin para Harbour/xHarbour Know the Column number clicked on the TXBrowse Header
Posts: 56
Joined: Tue Mar 23, 2010 12:53 PM
Know the Column number clicked on the TXBrowse Header
Posted: Wed Nov 16, 2022 09:23 PM
Hello

Is there any way to know which column (header was clicked by the User)



Example of clicking the header "fantasy" would be number 3


thank you all friend
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Know the Column number clicked on the TXBrowse Header
Posted: Thu Nov 17, 2022 08:54 AM
Here you have an example:
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oBrowser

   USE "clients"

   XBROWSER "clients" SETUP ( oBrowser := oBrw,;
      AEval( oBrw:aCols, { | o | o:bLClickHeader := { | nMRow, nMCol | MsgInfo( oBrowser:MouseColPos( nMCol ) ) } } ) )

return nil
Basically all you have to do is set the codeblock bLClickHeader for each column of the browser
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Know the Column number clicked on the TXBrowse Header
Posted: Thu Nov 17, 2022 09:07 AM
This version works also when the browse is scrolled:
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oBrowser, oColumn

   USE "clients"

   XBROWSER "clients" SETUP ( oBrowser := oBrw,;
      AEval( oBrw:aCols, { | o | o:bLClickHeader := { | nMRow, nMCol, nFlags, oCol | ;
      oColumn := oCol, MsgInfo( AScan( oBrowser:aCols, { | o | o == oColumn } ) ) } } ) )

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Know the Column number clicked on the TXBrowse Header
Posted: Thu Nov 17, 2022 09:20 AM
From Mr. Rao:
To know the column number when created.
oBrw:bLClickHeaders := { |r,c,f,oCol| MsgInfo( oCol:nCreationOrder ) }
To know the present position in the visible columns ( position in oBrw:aCols )
oBrw:bLClickHeaders := { |r,c,f,oCol| MsgInfo( oCol:nPos ) }
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
Re: Know the Column number clicked on the TXBrowse Header
Posted: Thu Nov 17, 2022 09:23 AM
So using Mr. Rao advise we can simplify the code even more:
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   USE "clients"

   XBROWSER "clients" SETUP oBrw:bLClickHeaders := { |r,c,f,oCol| MsgInfo( oCol:nCreationOrder ) }

return nil
or
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   USE "clients"

   XBROWSER "clients" SETUP oBrw:bLClickHeaders := { |r,c,f,oCol| MsgInfo( oCol:nPos ) }

return nil
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 56
Joined: Tue Mar 23, 2010 12:53 PM
Re: Know the Column number clicked on the TXBrowse Header
Posted: Thu Nov 17, 2022 11:49 AM
Thank you all
Solved like this, see the Code

My code
Code (fw): Select all Collapse
oCol := oDBx_Fornecedor:AddCol()
oCol:bStrData  := { || forneced->FANTASIA }
oCol:cHeader   := "Fantasia"
oCol:cFooter   := " "
oCol:nDataStrAlign := AL_LEFT
oCol:nHeadStrAlign := AL_LEFT
oCol:bLClickHeader := {|r,c,f,o| (  oDBx_Fornecedor:cFilterFld :=  'FANTASIA', PROCURA_FORNECED_SQL(cOrder,'FANTASIA',oDBx_Fornecedor:MouseColPos( c ) )    )}
oCol:cSortOrder := 'FANTASIA'
Code (fw): Select all Collapse
#include "FiveWin.ch"

function Main()

   local oBrowser

   USE "clients"

   XBROWSER "clients" SETUP ( oBrowser := oBrw,;
      AEval( oBrw:aCols, { | o | o:bLClickHeader := { | nMRow, nMCol | MsgInfo( oBrowser:MouseColPos( nMCol ) ) } } ) )

return nil

Continue the discussion