Combobox dropdown style - search

Combobox dropdown style - search

Postby Otto » Sun Feb 15, 2009 10:13 am

I can’t get "search" working in a dropdown style combobox .
What is wrong with my code?
Thanks in advance
Otto
Code: Select all  Expand view
 
// This sample shows how to create a Combo Test.
 
#include "FiveWin.ch"
 
//----------------------------------------------------------------------------//
 
function Main()
 
   local oDlg, oCbx, oSayItem, oSayAt
   local cItem := "Österreich  A               "
   local aItems:={}
 
 
 
 
AAdd( aItems,  "Österreich  A               "  )
AAdd( aItems,  "Albanien  AL                "  )
AAdd( aItems,  "Andorra  AND                "  )
AAdd( aItems,  "Amerikanisch-Samoa  ASM     "  )
AAdd( aItems,  "Belgien  B                  "  )
AAdd( aItems,  "Burgenland  BGL             "  )
AAdd( aItems,  "Bermuda  BMU                "  )
AAdd( aItems,  "Bahrain  BRN                "  )
AAdd( aItems,  "Myanmar  BUR                "  )
AAdd( aItems,  "Kuba  C                     "  )
AAdd( aItems,  "Coted'Ivoire  CI            "  )
AAdd( aItems,  "SriLanka  CL                "  )
AAdd( aItems,  "Komoren  COM                "  )
AAdd( aItems,  "KapVerde  CV                "  )
AAdd( aItems,  "Kaimaninseln  CYM           "  )
AAdd( aItems,  "Tschechische Republik  CZ   "  )
AAdd( aItems,  "Deutschland  D              "  )
AAdd( aItems,  "Dschibuti  DJI              "  )
AAdd( aItems,  "Dänemark  DK                "  )
AAdd( aItems,  "Dominikanische Republik  DOM"  )
AAdd( aItems,  "Algerien  DZ                "  )
AAdd( aItems,  "Spanien  E                  "  )
AAdd( aItems,  "Estland  EST                "  )
AAdd( aItems,  "Fidschi  FJI                "  )
AAdd( aItems,  "Französisch-Guayana  GF     "  )
AAdd( aItems,  "Guadeloupe  GLP             "  )
AAdd( aItems,  "Guinea  GN                  "  )
AAdd( aItems,  "Iran  IR                    "  )
AAdd( aItems,  "Irland  IRL                 "  )
AAdd( aItems,  "Island  IS                  "  )
AAdd( aItems,  "Japan  J                    "  )
AAdd( aItems,  "Kambodscha  K               "  )
AAdd( aItems,  "Kärnten  KTN                "  )
AAdd( aItems,  "Libyen  LAR                 "  )
AAdd( aItems,  "Liberia  LB                 "  )
AAdd( aItems,  "Aruba  ABW                  "  )
AAdd( aItems,  "Anguilla  AIA               "  )
AAdd( aItems,  "Antigua und Barbuda  ANT    "  )
AAdd( aItems,  "Armenien  ARM               "  )
AAdd( aItems,  "Australien  AUS             "  )
AAdd( aItems,  "Barbados  BDS               "  )
AAdd( aItems,  "Bolivien  BOL               "  )
AAdd( aItems,  "Bahamas  BS                 "  )
AAdd( aItems,  "Kokosinseln  CCK            "  )
AAdd( aItems,  "Schweiz  CH                 "  )
AAdd( aItems,  "Kolumbien  CO               "  )
AAdd( aItems,  "Cook-Inseln  COK            "  )
AAdd( aItems,  "Costa Rica  CR              "  )
AAdd( aItems,  "Zypern  CY                  "  )
AAdd( aItems,  "Kenia  EAK                  "  )
AAdd( aItems,  "Tansania  EAT               "  )
AAdd( aItems,  "Ecuador  EC                 "  )
AAdd( aItems,  "Eritrea  ER                 "  )
AAdd( aItems,  "El Salvador  ES             "  )
AAdd( aItems,  "Ägypten  ET                 "  )
AAdd( aItems,  "Äthiopien  ETH              "  )
AAdd( aItems,  "Finnland  FIN               "  )
AAdd( aItems,  "Falklandinseln  FLK         "  )
AAdd( aItems,  "Man  GBM                    "  )
AAdd( aItems,  "Guatemala  GCA              "  )
AAdd( aItems,  "Guam  GUM                   "  )
AAdd( aItems,  "Guyana  GUY                 "  )
AAdd( aItems,  "Honduras  HD                "  )
AAdd( aItems,  "Jordanien  HKJ              "  )
AAdd( aItems,  "Indien  IND                 "  )
AAdd( aItems,  "Britisches Territorium im  I"  )
AAdd( aItems,  "Irak  IRQ                   "  )
AAdd( aItems,  "Jamaika  JA                 "  )
AAdd( aItems,  "Johnston-Insel  JNI         "  )
AAdd( aItems,  "St.Kitts und Nevis  KN      "  )
AAdd( aItems,  "Laos  LAO                   "  )
AAdd( aItems,  "Lesotho  LS                 "  )
AAdd( aItems,  "Lettland  LV                "  )
AAdd( aItems,  "Malta  M                    "  )
AAdd( aItems,  "Marokko  MA                 "  )
AAdd( aItems,  "Macao  MAC                  "  )
AAdd( aItems,  "Malaysia  MAL               "  )
AAdd( aItems,  "Monaco  MC                  "  )
AAdd( aItems,  "Midway-Inseln  MID          "  )
AAdd( aItems,  "Mazedonien,ehem.jugoslaw.  M"  )
AAdd( aItems,  "Mosambik  MOC               "  )
AAdd( aItems,  "Mauritius  MS               "  )
AAdd( aItems,  "Montserrat  MSR             "  )
AAdd( aItems,  "Martinique  MTQ             "  )
AAdd( aItems,  "Malediven  MV               "  )
AAdd( aItems,  "Malawi  MW                  "  )
AAdd( aItems,  "NiederländischeAntillen  NA "  )
AAdd( aItems,  "Namibia  NAM                "  )
AAdd( aItems,  "Neukaledonien  NCL          "  )
AAdd( aItems,  "Nepal  NEP                  "  )
AAdd( aItems,  "Norfolkinsel  NFK           "  )
AAdd( aItems,  "Nicaragua  NIC              "  )
AAdd( aItems,  "Niue  NIU                   "  )
AAdd( aItems,  "Neuseeland  NZ              "  )
AAdd( aItems,  "Oman  O                     "  )
AAdd( aItems,  "Portugal  P                 "  )
AAdd( aItems,  "Panama  PA                  "  )
AAdd( aItems,  "Palästina  PAL              "  )
AAdd( aItems,  "Pitcairn  PCN               "  )
AAdd( aItems,  "Französisch-Polynesien  PF  "  )
AAdd( aItems,  "Philippinen  PHL            "  )
AAdd( aItems,  "Pakistan  PK                "  )
AAdd( aItems,  "Polen  PL                   "  )
AAdd( aItems,  "Papua-Neuguinea  PNG        "  )
AAdd( aItems,  "Katar  Q                    "  )
AAdd( aItems,  "Argentinien  RA             "  )
AAdd( aItems,  "Botsuana  RB                "  )
AAdd( aItems,  "Chile  RCH                  "  )
AAdd( aItems,  "Indonesien  RI              "  )
AAdd( aItems,  "Madagaskar  RM              "  )
AAdd( aItems,  "Niger  RN                   "  )
AAdd( aItems,  "Rumänien  RO                "  )
AAdd( aItems,  "Korea,Republik(Süd-)  ROK   "  )
AAdd( aItems,  "Uruguay  ROU                "  )
AAdd( aItems,  "Philippinen  RP             "  )
AAdd( aItems,  "San Marino  RSM             "  )
AAdd( aItems,  "Russische Föderation  RUS   "  )
AAdd( aItems,  "Afghanistan  AFG            "  )
AAdd( aItems,  "Angola  ANG                 "  )
AAdd( aItems,  "Aserbaidschan  AZ           "  )
AAdd( aItems,  "Bangladesch  BD             "  )
AAdd( aItems,  "Burkina Faso  BF            "  )
AAdd( aItems,  "Bulgarien  BG               "  )
AAdd( aItems,  "Belize  BH                  "  )
AAdd( aItems,  "Bosnien-Herzegowina  BIH    "  )
AAdd( aItems,  "Brasilien  BR               "  )
AAdd( aItems,  "Brunei  BRU                 "  )
AAdd( aItems,  "Bhutan  BTN                 "  )
AAdd( aItems,  "Belarus  BY                 "  )
AAdd( aItems,  "Kamerun  CAM                "  )
AAdd( aItems,  "Kanada  CDN                 "  )
AAdd( aItems,  "Tschechoslowakei(historis  C"  )
AAdd( aItems,  "Weihnachtsinsel  CXR        "  )
AAdd( aItems,  "Benin  DY                   "  )
AAdd( aItems,  "Uganda  EAU                 "  )
AAdd( aItems,  "Frankreich  F               "  )
AAdd( aItems,  "Liechtenstein  FL           "  )
AAdd( aItems,  "Färöer-Inseln  FR           "  )
AAdd( aItems,  "Mikronesien(Föderierte St  F"  )
AAdd( aItems,  "Gabun  GAB                  "  )
AAdd( aItems,  "Vereinigtes Königreich  GB  "  )
AAdd( aItems,  "Kanalinseln  GBG            "  )
AAdd( aItems,  "Gibraltar  GBZ              "  )
AAdd( aItems,  "Georgien  GE                "  )
AAdd( aItems,  "Ghana  GH                   "  )
AAdd( aItems,  "Guinea-Bissau  GNB          "  )
AAdd( aItems,  "Äquatorialguinea  GQ        "  )
AAdd( aItems,  "Griechenland  GR            "  )
AAdd( aItems,  "Grönland  GRO               "  )
AAdd( aItems,  "Ungarn  H                   "  )
AAdd( aItems,  "Hongkong  HK                "  )
AAdd( aItems,  "Kroatien  HR                "  )
AAdd( aItems,  "Italien  I                  "  )
AAdd( aItems,  "Israel  IL                  "  )
AAdd( aItems,  "Kiribati  KIR               "  )
AAdd( aItems,  "Kirgisistan  KS             "  )
AAdd( aItems,  "Kuwait  KWT                 "  )
AAdd( aItems,  "Kasachstan  KZ              "  )
AAdd( aItems,  "Luxemburg  L                "  )
AAdd( aItems,  "Litauen  LT                 "  )
AAdd( aItems,  "Moldau  MD                  "  )
AAdd( aItems,  "Mexiko  MEX                 "  )
AAdd( aItems,  "Marshall-Inseln  MH         "  )
AAdd( aItems,  "Mongolei  MNG               "  )
AAdd( aItems,  "Nördliche Marianen  MNP     "  )
AAdd( aItems,  "Mayotte  MYT                "  )
AAdd( aItems,  "Norwegen  N                 "  )
AAdd( aItems,  "Niederlande  NL             "  )
AAdd( aItems,  "Niederösterreich  NÖ        "  )
AAdd( aItems,  "Oberösterreich  OÖ          "  )
AAdd( aItems,  "Peru  PE                    "  )
AAdd( aItems,  "PuertoRico  PRI             "  )
AAdd( aItems,  "Korea,Demokratische Volks  P"  )
AAdd( aItems,  "Palau  PW                   "  )
AAdd( aItems,  "Paraguay  PY                "  )
AAdd( aItems,  "Zentralafrikanische Repub  R"  )
AAdd( aItems,  "Kongo  RCB                  "  )
AAdd( aItems,  "Reunion  REU                "  )
AAdd( aItems,  "Haiti  RH                   "  )
AAdd( aItems,  "Mauretanien  RIM            "  )
AAdd( aItems,  "Libanon  RL                 "  )
AAdd( aItems,  "Mali  RMM                   "  )
AAdd( aItems,  "Burundi  RU                 "  )
AAdd( aItems,  "Ruanda  RWA                 "  )
AAdd( aItems,  "Schweden  S                 "  )
AAdd( aItems,  "Saudi-Arabien  SA           "  )
AAdd( aItems,  "Salzburg  SBG               "  )
AAdd( aItems,  "Swasiland  SD               "  )
AAdd( aItems,  "Singapur  SGP               "  )
AAdd( aItems,  "Sankt Helena  SHN           "  )
AAdd( aItems,  "Slowakei  SK                "  )
AAdd( aItems,  "Salomonen  SLB              "  )
AAdd( aItems,  "Slowenien  SLO              "  )
AAdd( aItems,  "Suriname  SME               "  )
AAdd( aItems,  "Senegal  SN                 "  )
AAdd( aItems,  "Somalia  SP                 "  )
AAdd( aItems,  "Saint Pierre und Miquelon  S"  )
AAdd( aItems,  "Steiermark  STM             "  )
AAdd( aItems,  "Sao Tome und Principe  STP  "  )
AAdd( aItems,  "Sowjetunion(historischbis  S"  )
AAdd( aItems,  "Sudan  SUD                  "  )
AAdd( aItems,  "Seychellen  SY              "  )
AAdd( aItems,  "Syrien  SYR                 "  )
AAdd( aItems,  "Thailand  T                 "  )
AAdd( aItems,  "Turks-und Caicos-Inseln  TCA"  )
AAdd( aItems,  "Tschad  TCH                 "  )
AAdd( aItems,  "Togo  TG                    "  )
AAdd( aItems,  "Tirol  TIR                  "  )
AAdd( aItems,  "Tadschikistan  TJ           "  )
AAdd( aItems,  "Tokelau-Inseln  TKL         "  )
AAdd( aItems,  "Turkmenistan  TM            "  )
AAdd( aItems,  "Tunesien  TN                "  )
AAdd( aItems,  "Tonga  TO                   "  )
AAdd( aItems,  "Türkei  TR                  "  )
AAdd( aItems,  "Trinidad und Tobago  TT     "  )
AAdd( aItems,  "Tuvalu  TUV                 "  )
AAdd( aItems,  "China,Republik(Taiwan)  TWN "  )
AAdd( aItems,  "Ukraine  UA                 "  )
AAdd( aItems,  "Vereinigte Arabische Emir  U"  )
AAdd( aItems,  "Vereinigte Staaten von Am  U"  )
AAdd( aItems,  "Usbekistan  UZB             "  )
AAdd( aItems,  "Vatikanstadt  V             "  )
AAdd( aItems,  "Vorarlberg  VBG             "  )
AAdd( aItems,  "Britische Jungferninseln  VG"  )
AAdd( aItems,  "Amerikanische Jungfernins  V"  )
AAdd( aItems,  "Wien  VIE                   "  )
AAdd( aItems,  "Vietnam  VN                 "  )
AAdd( aItems,  "China(Volksrepublik)  VRC   "  )
AAdd( aItems,  "Vanuatu  VU                 "  )
AAdd( aItems,  "Gambia  WAG                 "  )
AAdd( aItems,  "Nauru  WAI                  "  )
AAdd( aItems,  "Sierra Leone  WAL           "  )
AAdd( aItems,  "Nigeria  WAN                "  )
AAdd( aItems,  "Dominica  WD                "  )
AAdd( aItems,  "Grenada  WG                 "  )
AAdd( aItems,  "Wake-Inseln  WKI            "  )
AAdd( aItems,  "St.Lucia  WL                "  )
AAdd( aItems,  "Wallis und Futuna  WLF      "  )
AAdd( aItems,  "Samoa(West-)  WS            "  )
AAdd( aItems,  "St.Vincent und die Grenad  W"  )
AAdd( aItems,  "Jemen  Y                    "  )
AAdd( aItems,  "Jugoslawien(SerbienundMon  Y"  )
AAdd( aItems,  "Jugoslawien(historischbis  Y"  )
AAdd( aItems,  "Venezuela  YV               "  )
AAdd( aItems,  "Sambia  Z                   "  )
AAdd( aItems,  "Südafrika  ZA               "  )
AAdd( aItems,  "Zaire  ZRE                  "  )
AAdd( aItems,  "Simbabwe  ZW                "  )
AAdd( aItems,  "Staatenlos  ZZX             "  )
AAdd( aItems,  "Ungeklärt  ZZY              "  )
AAdd( aItems,  "Unbekannt  ZZZ              "  )
AAdd( aItems,  "                "                                )
 
 
 
 
 
   SET _3DLOOK ON
 
   DEFINE DIALOg oDlg RESOURCE "TestCombo"
 
   REDEFINE COMBOBOX oCbx VAR cItem ITEMS aItems ;
      ID 110 OF oDlg          ;
      ON CHANGE ( oSayItem:cTitle := oCbx:GetText() ) ;
      VALID ( MsgBeep(), .t. )
 
   REDEFINE SAY oSayItem ID 120 OF oDlg
 
 
 
 
 
   ACTIVATE DIALOG oDlg CENTERED
 
return nil
 


rc-file


Code: Select all  Expand view
 
#include "..\include\WinApi.ch"
 
LANGUAGE LANG_ENGLISH,SUBLANG_ENGLISH_US
 
TESTCOMBO DIALOG DISCARDABLE 49, 30, 371, 190
STYLE WS_POPUP|DS_MODALFRAME|WS_CAPTION|WS_SYSMENU
CAPTION "Testing a ComboBox"
BEGIN
  CONTROL "A ComboBox", -1, "Static", WS_GROUP, 10, 5, 43, 8
  CONTROL "", 110, "ComboBox", WS_BORDER|CBS_DROPDOWN|CBS_SORT|WS_TABSTOP, 8, 16, 156, 144
  CONTROL "&Selected Item:", -1, "Static", WS_GROUP, 192, 116, 48, 8
  CONTROL "", 120, "Static", WS_GROUP, 192, 128, 70, 8
  CONTROL "", -1, "Static", SS_ICON, 200, 144, 16, 16
  CONTROL "&End", IDCANCEL, "Button", WS_TABSTOP, 264, 84, 33, 12
END
FIVEWIN ICON "..\\icons\\fivewin.ico"
 
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6045
Joined: Fri Oct 07, 2005 7:07 pm

Re: Combobox dropdown style - search

Postby ukoenig » Sun Feb 15, 2009 2:12 pm

Otto

Thanks, it works fine.

Maybe You like this little change ?

Image

Code: Select all  Expand view
  
local cItem := xPADR ('Österreich', 200) + 'A               '
local aItems:={} AAdd( aItems,  xPADR ('Österreich', 200) + 'A               '  )
 
AAdd( aItems,  xPADR ('Albanien', 200) + 'AL                '  )
AAdd( aItems,  xPADR ('Andorra', 200) + 'AND                '  )
AAdd( aItems,  xPADR ('Amerikanisch-Samoa', 200) + 'ASM     '  )
AAdd( aItems,  xPADR ('Belgien', 200) + 'B                  '  )
AAdd( aItems,  xPADR ('Burgenland', 200) + 'BGL             '  )
 


xPADR fills a string to a given pixel-length, but it seems, it is not 100 % adjusted.
Do You have any solution for it ?

Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Combobox dropdown style - search

Postby Otto » Sun Feb 15, 2009 3:17 pm

Hallo Uwe,
könntest du mir bitte deine exe mailen eventuell auch deine combobox.prg.
Danke.
Mit freundlichem Gruß
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6045
Joined: Fri Oct 07, 2005 7:07 pm

Re: Combobox dropdown style - search

Postby ukoenig » Sun Feb 15, 2009 5:09 pm

Hello Otto,

For selected Countrys, change the defined Length 220 Pixel to 200 Pixel
As well You can do some fine-adjustment, to bring some not exact adjusted text in vertical-line.

Image

The modified Array ( prg ) I send You by Email.

Regards
Uwe :lol:
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Combobox dropdown style - search

Postby Otto » Sun Feb 15, 2009 5:19 pm

Hello Uwe,

thank you for your help.
My problem is not the way of displaying the data.
The problem is that if I press for example key “B” that the combobox does not search for the first country starting with “B”.
I am waiting for your exe.
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: 6045
Joined: Fri Oct 07, 2005 7:07 pm

Re: Combobox dropdown style - search

Postby Otto » Sun Feb 15, 2009 7:21 pm

Thank you Uwe.
But you changed the style to CBS_DROPDOWNLIST.
I need CBS_DROPDOWN.

I think I need the help of Antonio.
This worked in FIVEWIN 16 bit but I can’t get this functionality in FWH.
Thank you and 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: 6045
Joined: Fri Oct 07, 2005 7:07 pm

Re: Combobox dropdown style - search

Postby Otto » Mon Feb 16, 2009 12:13 am

I tried to search with:

Code: Select all  Expand view
oCbx:oGet:bKeyChar = { | nKey |  cKey := chr(nKey), nNewAt := AScan(aItems, {|x| Upper(x) = Upper(cKey) } )  ,;
       iif(nNewAt > 0,( oCbx:Select( nNewAt )                     )  ,)  }



Search would work – but I can’t find out how to update the combobox.

I tried to update the combobox with:

Code: Select all  Expand view
Eval( oCbx:bSetGet, aItems[ nNewAt ]


But this errors out.

Does someone have a combobox dropdown – not dropdownlist working?

Thanks in advance
Otto


Application
===========
Path and name: C:\uwe\testcomb.exe (32 bits)
Size: 1,659,904 bytes
Time from start: 0 hours 0 mins 3 secs
Error occurred at: 02/16/09, 01:10:10
Error description: Error BASE/1070 Argument error: ==
Args:
[ 1] = C Tadschikistan TJ
[ 2] = N 0

Stack Calls
===========
Called from: .\source\classes\TGET.PRG => TGET:KEYCHAR(0)
Called from: => TWINDOW:HANDLEEVENT(0)
Called from: .\source\classes\CONTROL.PRG => TCONTROL:HANDLEEVENT(0)
Called from: .\source\classes\TGET.PRG => TGET:HANDLEEVENT(0)
Called from: .\source\classes\WINDOW.PRG => _FWH(0)
Called from: => DIALOGBOX(0)
Called from: .\source\classes\DIALOG.PRG => TDIALOG:ACTIVATE(0)
Called from: C:\uwe\testcomb.prg => MAIN(306)
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6045
Joined: Fri Oct 07, 2005 7:07 pm

Re: Combobox dropdown style - search

Postby Daniel Garcia-Gil » Mon Feb 16, 2009 1:34 am

hello otto...

maybe this is a way... please check it

Code: Select all  Expand view
  oCbx:bKeyDown = { | nKey |  cKey := chr(nKey), nNewAt := AScan(aItems, {|x| Upper(x) = Upper(cKey) } )  ,;
       iif(nNewAt > 0,( oCbx:oGet:VarPut(aItems[ nNewAt ] ) , oCbx:oGet:refresh()), )  }
 
User avatar
Daniel Garcia-Gil
 
Posts: 2365
Joined: Wed Nov 02, 2005 11:46 pm
Location: Isla de Margarita

Re: Combobox dropdown style - search

Postby demont frank » Mon Feb 16, 2009 10:04 am

Otto,

Combobox has some limitations : it can only use one dimensional array. In your sample a two dimensional array should be much better , each column can be a search column and the layout is much better.

I made a comboclass , first with tsbrowse , now with xbrowse. Till a few month agoa building a class for it , now using a xbrowse defined without the TO odlg clausule. Your example would be :

Code: Select all  Expand view

Function module4(oWnd)

   local oDlg, oGet , oSay
   local cItem := "Österreich  A               "
   local aItems:={}

AAdd( aItems,  "Österreich  A               "  )
AAdd( aItems,  "Belgien  B                  "  )
/* ....... */

aItems := Make2Dim(aItems)  // Aadd also index number (recno)
cItem := "B  "

   SET _3DLOOK ON

@ 0,0 XBROWSE oBrw ARRAY aItems AUTOSORT;
    COLUMNS 1,2,3;
    SIZES 30,100,50;
    HEADERS "Code","Country Name","Recno"
oBrw:aCols[3]:Hide()   // Recno
oBrw:aCols[1]:bOrder := {|Arr|Nm_Alfa(Arr[1],.F.)}

DEFINE DIALOg oDlg RESOURCE "TestCombo"

    REDEFINE GET oGet VAR cItem ID 110 OF oDlg PICTURE "@K"  //VALID Inp > "b"
        MakeGetBox(oGet,1,oBrw)            // 1 : seekcol number , this column must update the get
        oGet:cBmpName := "BITMAPS\xCombox2.bmp"
    REDEFINE SAY oSay ID 120 OF oDlg
        oGet:LinkBlock(oSay,2)        // 2 : this column must update the say from oGet
        oGet:Makelink(.T.)               // The say receives his value

REDEFINE BUTTON ID 200 ACTION oDLg:End()

ACTIVATE DIALOG oDlg CENTERED
return nil

 


The inputfield is only the code from the country , maximum 3 characters. When not found , or when clicked on the get-button , the search xbrowse is activated as a combobox.
Each column can be search column , only characterset from 32-127 are used , so to seek to NÖ you have to type NO

Frank
demont frank
 
Posts: 167
Joined: Thu Mar 22, 2007 11:24 am

Re: Combobox dropdown style - search

Postby StefanHaupt » Mon Feb 16, 2009 11:38 am

Hi Otto,

I found this code snippet in my archiv, 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: Combobox dropdown style - search

Postby Otto » Mon Feb 16, 2009 12:12 pm

Hello Daniel, hello Frank,
thank you for your help.
Frank, I would prefer staying with combobox for this task.

Daniel, your suggestion is working.

Code: Select all  Expand view
oCbx:bKeyDown = { | nKey | iif(nKey=40,(lSeek :=.f.,cKey:=""), ),;    
       iif(nKey=38, (lSeek :=.f.,cKey:=""), ),;
       cKey := cKey + chr(nKey), nNewAt := AScan(aItems,{|x| Upper(x) = Upper(cKey) } )  ,;
       iif( (nNewAt > 0  .and. lSeek =.f.) ,;
       ( oCbx:Select( nNewAt ) ,;
       oCbx:oGet:VarPut(  UPPER(aItems[ nNewAt ]) ) , oCbx:oGet:refresh() ), lSeek :=.t.)  }


I tried to insert this code to enable incremental search.
Could you help me please again.
I can’t find how to synchronize the input field. If I insert a key now it is always shown on the first position.
Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6045
Joined: Fri Oct 07, 2005 7:07 pm

Re: Combobox dropdown style - search

Postby Otto » Mon Feb 16, 2009 6:41 pm

Hello Frank,

As I can’t get working incremental search in combobox I would like to test your solution with xBrowse.
Would you be so kind to send me following functions:
MAKE2DIM
NM_ALFA
MAKEGETBOX

Thanks in advance
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6045
Joined: Fri Oct 07, 2005 7:07 pm

Re: Combobox dropdown style - search

Postby ukoenig » Mon Feb 16, 2009 6:46 pm

Hello Otto,

That works, but it might be just the basics, to work on. I think, it can be done better.
The edit Char is always on the left-hand-side. Maybe there ia a way to place the cursor ?
The result is shown with some space next to the char.
The SPACE - Button clears the Input.
The DEL-Button ( Bottom-right of the Numeric-block ) deletes the last char.
Incremental-search works with this solution.
I modifyed the search-string : the first char has to be Upper, the rest lower.
All incoming chars are lower
That means : < United States > works with United but S ( States ) is converted to Lower.
You can solve it with : convert to upper, if the char before is a space.

Image

Code: Select all  Expand view


REDEFINE COMBOBOX oCbx VAR cItem ITEMS aItems ; //   { "Testing", "this", "ComboBox" } ;
      ID 110 OF oDlg ;
      ON CHANGE ( oSayItem:cTitle := cItem,;   // We should use also :SetText()
                  oSayAt:cTitle   := ":nAt = " + Str( oCbx:nAt, 2 ) ) ;
      VALID ( MsgBeep(), .t. )

oCbx:bKeyDown = { | nKey |  Increment(oCbx,nKey,cItem,aItems,oSayItem) }

REDEFINE SAY oSayItem VAR cSAY ID 120 OF oDlg

---------------------------------------------------------------------------//

FUNCTION Increment(oCbx,nKey,cItem,aItems,oSayItem)

IF nKey = 32    // SPACE clears display
    cItem := ""
ENDIF
IF nKey = 110    // Delete last Char (  use from numeric block )
    cItem := Substr(cItem, 1, LEN(cItem) - 1 )
ELSE
    cKey := LOWER(chr(nKey))   //  numeric to CHAR
    cItem := LTRIM( cItem + cKey )
    cItem := Substr(Upper(cItem),1,1) + Substr(cItem, 2, LEN(cItem) )
ENDIF
// Shows single-char, some space + the search-string
// -----------------------------------------------------------
oCbx:oGet:VarPut( "     " + cItem )  // left space for result
nNewAt := AScan(aItems, cItem )  

// Replace the SAY with the Result
// --------------------------------------
IF nNewAt > 0
    oSayItem:VarPut( aItems[ nNewAt ] )
ENDIF   
oCbx:oGet:refresh()
oSayItem:Refresh()

RETURN NIL

 


Regards
Uwe :lol:
Last edited by ukoenig on Mon Feb 16, 2009 7:24 pm, edited 4 times in total.
Since 1995 ( the first release of FW 1.9 )
i work with FW.
If you have any questions about special functions, maybe i can help.
User avatar
ukoenig
 
Posts: 4043
Joined: Wed Dec 19, 2007 6:40 pm
Location: Germany

Re: Combobox dropdown style - search

Postby James Bott » Mon Feb 16, 2009 7:02 pm

Otto,

Try this:

REDEFINE COMBOBOX oCbx VAR cItem ITEMS aItems ;
ID 110 OF oDlg
oCbx:lIncSearch:=.t.

lIncSearch is a new var in ver 8.08 and it defaults to .f., so you have to turn it on to get incremental searching.

Regards,
James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Combobox dropdown style - search

Postby Otto » Mon Feb 16, 2009 10:35 pm

Hello James
Thank you for your help.
I tried your suggestion: oCbx:lIncSearch:=.t.
But does not turn on the searching.

Uwe, your incremental function has the same problem as my own attempts. The get field is not filled.

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: 6045
Joined: Fri Oct 07, 2005 7:07 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 29 guests

cron