Character Search within ComboBox

Character Search within ComboBox

Postby cdmmaui » Thu Mar 08, 2012 4: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
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Character Search within ComboBox

Postby MarcoBoschi » 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 ) ) ) )
User avatar
MarcoBoschi
 
Posts: 1065
Joined: Thu Nov 17, 2005 11:08 am
Location: Padova - Italy

Re: Character Search within ComboBox

Postby cdmmaui » Wed Aug 15, 2012 5: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
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong

Re: Character Search within ComboBox

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

Re: Character Search within ComboBox

Postby cdmmaui » Wed Aug 15, 2012 3: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
User avatar
cdmmaui
 
Posts: 689
Joined: Fri Oct 28, 2005 9:53 am
Location: Houston ∙ Chicago ∙ Los Angeles ∙ Miami ∙ London ∙ Hong Kong


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 63 guests