Combo box incremental search

Combo box incremental search

Postby TimStone » Tue Jul 03, 2012 9:06 pm

The class for the combobox ( dropdown ) shows a lIncSearch data item which would appear to implement a method that permits incremental searching of a list ( array ).

However: oCombo:lIncSearch := .t.

Does not activate such an activity.

What am I missing here ? I have clients who have a very long list in the box and want to move the highlight bar based on what they are typing !

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Combo box incremental search

Postby Otto » Wed Jul 04, 2012 6:10 am

Hello Tim,
I would suggest you to use comboM (TComboMetro).
The new combo class (source\combom.prg) uses internally a xBrowse with all the xBrowse power.

Best regards,
Otto

Image

Image
Last edited by Otto on Wed Jul 04, 2012 8:21 am, edited 1 time in total.
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Combo box incremental search

Postby StefanHaupt » Wed Jul 04, 2012 7:30 am

Hi Tim,

here is an implementation of an incremental search in a combobox. I did not test it, but maybe it helps.

Code: Select all  Expand view
/*
Purpose  : Provides incremental search to a regular combobox.
Notes    : After defining your ComboBox run SetIncr(oCbx).
         : Include the attached prg in your project.
Author   : Byron Hopp, (Matrix Computer Services) <mcs3@ix.netcom.com>
Date     : 7/1/00

Notes: There is no handling of backspaces. You can use the up and down arrow
keys also (while the dropdown is not down). Using a space resets the seach.

Modified to make case insensitive and to handle DBCombo's also, by James
Bott, 5/21/04. Tested under FWH 2.4/Harbour 43.
*/


FUNCTION SetIncr(oCbx)
    oCbx:bKeyChar   := {|nKey,nFlags| FindIncr(oCbx,nKey)}
    oCbx:bGotFocus  := {|| oCbx:Cargo := "",oCbx:SetFocus()}
RETURN NIL

FUNCTION FindIncr(oCbx,nKey)
    LOCAL  nNewEle  := 0
    IF nKey <> 32
        oCbx:Cargo += upper( CHR(nKey) )
        if oCbx:classname =="TCOMBOBOX"
           oCbx:Set(IIF( (nNewEle := ASCAN(oCbx:aItems, {|x| upper(x) =
oCbx:Cargo} )) > 0,nNewEle,oCbx:nAT))
        else // for TDBCombo
           oCbx:Set(IIF( (nNewEle := ASCAN(oCbx:aList, {|x| upper(x) =
oCbx:Cargo} )) > 0,nNewEle,oCbx:nAT))
        endif
     ELSE
        oCbx:Cargo := ""
        oCbx:Set(1)
    ENDIF
RETURN oCbx:nAT
 
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: Combo box incremental search

Postby TimStone » Thu Jul 05, 2012 5:15 pm

Stefan,

I tried it ... once the Get got focus, it just constantly ran, flashing, with no escape.

Otto,

This is not a metro app ...


Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Combo box incremental search

Postby Otto » Thu Jul 05, 2012 6:14 pm

Tim,
you can use ComboM with a Standard WINDOWS application.
I think the use of xBrowse insite the comboBox offers great possibilities.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Combo box incremental search

Postby TimStone » Fri Jul 06, 2012 12:05 am

Otto,

My program uses resources for all the dialogs and controls.

I did look at the control you suggested, but it does not appear to allow a REDEFINE of an RC control ...
Perhaps I am missing something essential and you can point me to a sample.

Thanks.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Combo box incremental search

Postby Otto » Fri Jul 06, 2012 7:17 am

Hello Tim,
yes you are right. I didn't thought on that.
I don't think that this option will be built in as the use of resources is not useful for Metro inspired programs.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6332
Joined: Fri Oct 07, 2005 7:07 pm

Re: Combo box incremental search

Postby Antonio Linares » Fri Jul 06, 2012 10:02 am

Tim,

This example works fine but requires that the user types the whole item chars:

test.prg
Code: Select all  Expand view
#include "FiveWin.ch"

function Main()

   local oDlg, oCbx, cSearch := Space( 100 ), aItems := { "africa", "america", "asia", "europe", "oceania" }

   DEFINE DIALOG oDlg SIZE 400, 300

   @ 2.4, 1.2 COMBOBOX oCbx VAR cSearch ITEMS aItems OF oDlg SIZE 180, 150

   oCbx:lIncSearch = .T.

   ACTIVATE DIALOG oDlg CENTERED

return nil


With this litte change in FWH Class TComboBox is no longer needed that you write all its chars :-)
line 557 combobox.prg
Code: Select all  Expand view
           if ::lCaseSensitive
               nNewAt = AScan( ::aItems, { | x | SubStr( x, 1, Len( ::cSearchKey ) ) == ::cSearchKey } )
            else
               nNewAt = AScan( ::aItems, { | x | SubStr( Upper( x ), 1, Len( ::cSearchKey ) ) == ::cSearchKey } )
            endif
 
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: Combo box incremental search

Postby TimStone » Fri Jul 06, 2012 8:30 pm

.
Last edited by TimStone on Fri Jul 06, 2012 8:34 pm, edited 1 time in total.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Combo box incremental search

Postby TimStone » Fri Jul 06, 2012 8:33 pm

I made the changes and linked in combobox.prg

I'm calling the combobox this way:

REDEFINE COMBOBOX oCmboBx VAR oInvr:invman ITEMS aMan ID 767 OF oDiw STYLE CBS_DROPDOWN ;
MESSAGE "Enter the manufacturer of this product" UPDATE
oCmboBx:lIncSearch := .t.

And the control is:

CONTROL "", 767, "ComboBox", WS_BORDER|CBS_DROPDOWN|WS_VSCROLL|WS_TABSTOP, 248, 55, 92, 162

However, it does not function properly ....

Actually Its not refreshing the value in the get when I type, but if I click on the down arrow, the proper element is highlighted.

Tim

What is wrong with the above ?

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Combo box incremental search

Postby Antonio Linares » Fri Jul 06, 2012 8:38 pm

The problem is that you are uisng the CBS_DROPDOWN style and it is not assumed to be used.

We could implement it for that case too. But then you will have to control with the VALID that the typed item is one of the existing items.

If you don't use the CBS_DROPDOWN style, then the user can only type valid items contents.

I am not sure if I am properly explaining it :-)
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: Combo box incremental search

Postby TimStone » Fri Jul 06, 2012 8:57 pm

So what style / control should I use ( I assume both in the REDEFINE and the .rc ) ?
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: Combo box incremental search

Postby Antonio Linares » Sat Jul 07, 2012 12:24 pm

In the resources you use: CBS_DROPDOWNLIST and in the PRG you don't need any.

Please run FWH\samples\combos.prg. The one on the right is the right one :-)

You can review combos.rc to see how it is declared, thanks
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: Combo box incremental search

Postby TimStone » Sat Jul 07, 2012 9:31 pm

The problem is that we need to be able to add an entry not on the list ...

People like to just type in values sometimes ( or always ).

That, by definition, is the combobox vs the drop down list.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2944
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 114 guests

cron