Know the Column number clicked on the TXBrowse Header

Know the Column number clicked on the TXBrowse Header

Postby INFORMAISVRB » Wed Nov 16, 2022 9:23 pm

Hello

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

Image

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


thank you all friend
INFORMAISVRB
 
Posts: 51
Joined: Tue Mar 23, 2010 12:53 pm

Re: Know the Column number clicked on the TXBrowse Header

Postby Antonio Linares » Thu Nov 17, 2022 8:54 am

Here you have an example:
Code: Select all  Expand view  RUN
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Know the Column number clicked on the TXBrowse Header

Postby Antonio Linares » Thu Nov 17, 2022 9:07 am

This version works also when the browse is scrolled:
Code: Select all  Expand view  RUN
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Know the Column number clicked on the TXBrowse Header

Postby Antonio Linares » Thu Nov 17, 2022 9: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Know the Column number clicked on the TXBrowse Header

Postby Antonio Linares » Thu Nov 17, 2022 9:23 am

So using Mr. Rao advise we can simplify the code even more:
Code: Select all  Expand view  RUN
#include "FiveWin.ch"

function Main()

   USE "clients"

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

return nil

or
Code: Select all  Expand view  RUN
#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
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: Know the Column number clicked on the TXBrowse Header

Postby INFORMAISVRB » Thu Nov 17, 2022 11:49 am

Thank you all
Solved like this, see the Code

My code
Code: Select all  Expand view  RUN

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: Select all  Expand view  RUN

#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
 
INFORMAISVRB
 
Posts: 51
Joined: Tue Mar 23, 2010 12:53 pm


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 45 guests