Combo box incremental search
- TimStone
- Posts: 2968
- Joined: Fri Oct 07, 2005 1:45 pm
- Location: Trabuco Canyon, CA USA
- Has thanked: 25 times
- Been thanked: 6 times
- Contact:
Combo box incremental search
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
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
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
- Otto
- Posts: 6426
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 48 times
- Been thanked: 13 times
- Contact:
Re: Combo box incremental search
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


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


Last edited by Otto on Wed Jul 04, 2012 8:21 am, edited 1 time in total.
-
- Posts: 824
- Joined: Thu Oct 13, 2005 7:39 am
- Location: Germany
Re: Combo box incremental search
Hi Tim,
here is an implementation of an incremental search in a combobox. I did not test it, but maybe it helps.
here is an implementation of an incremental search in a combobox. I did not test it, but maybe it helps.
Code: Select all | Expand
/*
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
Stefan
- TimStone
- Posts: 2968
- Joined: Fri Oct 07, 2005 1:45 pm
- Location: Trabuco Canyon, CA USA
- Has thanked: 25 times
- Been thanked: 6 times
- Contact:
Re: Combo box incremental search
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
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
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
- Otto
- Posts: 6426
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 48 times
- Been thanked: 13 times
- Contact:
Re: Combo box incremental search
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
you can use ComboM with a Standard WINDOWS application.
I think the use of xBrowse insite the comboBox offers great possibilities.
Best regards,
Otto
- TimStone
- Posts: 2968
- Joined: Fri Oct 07, 2005 1:45 pm
- Location: Trabuco Canyon, CA USA
- Has thanked: 25 times
- Been thanked: 6 times
- Contact:
Re: Combo box incremental search
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
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
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
- Otto
- Posts: 6426
- Joined: Fri Oct 07, 2005 7:07 pm
- Has thanked: 48 times
- Been thanked: 13 times
- Contact:
Re: Combo box incremental search
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
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
- Antonio Linares
- Site Admin
- Posts: 42831
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 155 times
- Been thanked: 119 times
- Contact:
Re: Combo box incremental search
Tim,
This example works fine but requires that the user types the whole item chars:
test.prg
With this litte change in FWH Class TComboBox is no longer needed that you write all its chars
line 557 combobox.prg
This example works fine but requires that the user types the whole item chars:
test.prg
Code: Select all | Expand
#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
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
- TimStone
- Posts: 2968
- Joined: Fri Oct 07, 2005 1:45 pm
- Location: Trabuco Canyon, CA USA
- Has thanked: 25 times
- Been thanked: 6 times
- Contact:
Re: Combo box incremental search
.
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
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
- TimStone
- Posts: 2968
- Joined: Fri Oct 07, 2005 1:45 pm
- Location: Trabuco Canyon, CA USA
- Has thanked: 25 times
- Been thanked: 6 times
- Contact:
Re: Combo box incremental search
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
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
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
- Antonio Linares
- Site Admin
- Posts: 42831
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 155 times
- Been thanked: 119 times
- Contact:
Re: Combo box incremental search
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
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

- TimStone
- Posts: 2968
- Joined: Fri Oct 07, 2005 1:45 pm
- Location: Trabuco Canyon, CA USA
- Has thanked: 25 times
- Been thanked: 6 times
- Contact:
Re: Combo box incremental search
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
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
- Antonio Linares
- Site Admin
- Posts: 42831
- Joined: Thu Oct 06, 2005 5:47 pm
- Location: Spain
- Has thanked: 155 times
- Been thanked: 119 times
- Contact:
Re: Combo box incremental search
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
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
- TimStone
- Posts: 2968
- Joined: Fri Oct 07, 2005 1:45 pm
- Location: Trabuco Canyon, CA USA
- Has thanked: 25 times
- Been thanked: 6 times
- Contact:
Re: Combo box incremental search
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
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
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