FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Character Search within ComboBox
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Character Search within ComboBox
Posted: Thu Mar 08, 2012 04:34 PM

Hello,

Is it possible to search for characrters within a ComboBox for example, if user types chacters CT it move to CTN instead of moving to TUB (first item that begins with T). I tried the following code with no luck.

REDEFINE COMBOBOX aGet[5] VAR cUnit ID 105 ITEMS aUnit OF oDlg STYLE CBS_DROPDOWN <<<-------- I JUST ADDED THIS AND HAD NO EFFECT EITHER.
aGet[5]:oGet:bKeyDown = { | nKey | ComboSearchItem( nKey, aGet[5] ) }

//----------------------------------------------------------------------------//
function ComboSearchItem( nKey, oCbx )

local nAt

if Len( AllTrim( oCbx:oGet:GetText() ) ) == 1
if ( nAt := AScan( oCbx:aItems, { | c | Left( c, 1 ) == AllTrim( oCbx:oGet:GetText() ) } ) ) != 0
oCbx:oGet:SetText( oCbx:aItems[ nAt ] )
return 0
endif
endif

return nKey

*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Posts: 1091
Joined: Thu Nov 17, 2005 11:08 AM
Re: Character Search within ComboBox
Posted: Fri Mar 09, 2012 12:14 PM

try this:

@ 1 , 1 COMBOBOX oCombo VAR cCombo OF oDLG ITEMS aItems STYLE CBS_DROPDOWN SIZE 100 , 200
@ 1 , 20 GET oGet VAR cGet OF oDlg

oCombo:lIncSearch := .T.
oCombo:oGet:bKeyChar = { | nKey | premi_combo( nKey, oCombo ) }

ACTIVATE DIALOG oDlg CENTER

RETURN NIL

FUNCTION PREMI_COMBO( nKey , oCombo )
DO CASE
CASE nKey = VK_RETURN
nKey := VK_TAB
OTHERWISE

ENDCASE

RETURN oCombo:KeyChar( ASC( UPPER( CHR( nKey ) ) ) )

Marco Boschi
info@marcoboschi.it
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Re: Character Search within ComboBox
Posted: Wed Aug 15, 2012 05:05 AM

Hello Marco,

I tried this and it did not work. I trying to peform the following within a combobox. For example if the items consists of the following: LOT, LBS, PCS, PKG, PLT, PND, PPL

I want the user to be able press keys PLT and move directly item PLT, now when the user presses P it goes to first p, in this case PCS, but then when they press L, it goes to first L, in this case LOT.

Is something available that could help?

Thank you,

*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: Character Search within ComboBox
Posted: Wed Aug 15, 2012 11:24 AM

Darrell,

You just need to do:

oComboBox:lIncSearch = .T.

With more recent FWH version, it is not needed that the user types the whole word. It searches on each keystroke:

viewtopic.php?p=131939#p131939

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 708
Joined: Fri Oct 28, 2005 09:53 AM
Re: Character Search within ComboBox
Posted: Wed Aug 15, 2012 03:07 PM

Hi Antonio,

I am using FWHX 11.11; I will try now.

Thank you,

*~*~*~*~*~*~*~*~*~*
Darrell Ortiz
CDM Software Solutions, Inc.
https://www.cdmsoft.com

Continue the discussion