FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Allow a write in Get in a Combobox
Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Allow a write in Get in a Combobox
Posted: Sat Sep 02, 2017 07:50 PM
To All

Is there a way to be able to manually over-ride a Combobox to allow a Write in Get ? .. I have a login screen and I am populating a combobox array with Employee UserId's ..

I have a back-door user named 'Admin' and I do not want to populate the UserId array with that login .. and would like to be able to over-ride the combobox at runtime to accept a write in get ... I can not think of a way to do that ...

Any Ideas ?

Thanks
Rick Lipkin

Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: Allow a write in Get in a Combobox
Posted: Sat Sep 02, 2017 08:24 PM

Give style CBS_DROPDOWN to the combobox.

EMG

Posts: 2706
Joined: Fri Oct 07, 2005 01:50 PM
Re: Allow a write in Get in a Combobox
Posted: Mon Sep 04, 2017 03:50 PM

Enrico

Worked Great ... Many Thanks!

Rick Lipkin

Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
Re: Allow a write in Get in a Combobox
Posted: Mon Sep 04, 2017 07:24 PM

Algun sample pero de busqueda secuencial pero con DBCOMBO.? asi como en este combobox que cuando vaya escribiendo, ubique la coincidencia, saludos...gracias... :shock:

Some sample but sequential search but with DBCOMBO? as in this combobox that when you write, locate the match, greetings ... thanks ... :shock:

Dios no está muerto...



Gracias a mi Dios ante todo!
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Allow a write in Get in a Combobox
Posted: Mon Sep 04, 2017 10:33 PM

Jose,

You must set oDB:incSearch := .t.

The default is .f.

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
Re: Allow a write in Get in a Combobox
Posted: Mon Sep 04, 2017 11:36 PM
James Bott wrote:Jose,

You must set oDB:incSearch := .t.

The default is .f.


James, gracias por tu respuesta, pero parece esa data no pertenece a DBCOMBO, no confundir con COMBOBOX, la use como me dijistes y obtengo el siguiente error...alguna idea.? saludos...gracias... :-)

James, thanks for your reply, but it seems that data does not belong to DBCOMBO, do not confuse with COMBOBOX, use it as you told me and I get the following error ... any ideas.? greetings thank you... :-)

Code (fw): Select all Collapse
   REDEFINE DBCOMBO aGet[2] VAR aVar[2] ID 4020 OF oDlg UPDATE ;
      ITEMS aProvee1 ;
      LIST  aProvee2
   aGet[2]:incSearch := .t.

// aGet[2]:lIncSearch := .t. // TRY WITH THIS AND DOES NOT ERROR BUT DOES NOT GIVE SEQUENTIAL SEARCH .. - INTENTE CON ESTE Y NO DA ERROR PERO NO DA LA BUSQUEDA SECUENCIAL..


Time from start: 0 hours 5 mins 54 secs
Error occurred at: 04/09/2017, 19:33:29
Error description: Error BASE/1005 Message not found: TDBCOMBO:_INCSEARCH
Args:
[ 1] = O TDBCOMBO

Stack Calls
===========
Called from: => __ERRRT_SBASE( 0 )
Called from: ../../../tobject.prg => TDBCOMBO:ERROR( 0 )
Called from: ../../../tobject.prg => (b)HBOBJECT( 0 )
Called from: ../../../tobject.prg => TDBCOMBO:MSGNOTFOUND( 0 )
Called from: ../../../tobject.prg => TDBCOMBO:_INCSEARCH( 0 )
Called from: ma_compras.prg => DAT_LIBCOM( 132 )
Dios no está muerto...



Gracias a mi Dios ante todo!
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: Allow a write in Get in a Combobox
Posted: Tue Sep 05, 2017 05:37 AM

Jose,

Sorry, Jose, yes it should have been oDBC:lIncSearch.

I have not use a DBCombo in some time. I wrote the original incremental search code for the TDBCombo class but it was since moved into the parent class, TCombobox. I have in my notes that moving the code to TComobox broke it for DBCombo but I don't know if that was ever fixed. It is late now, but I will try to look at it tomorrow.

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
Re: Allow a write in Get in a Combobox
Posted: Tue Sep 05, 2017 10:46 PM
James Bott wrote:Jose,

Sorry, Jose, yes it should have been oDBC:lIncSearch.

I have not use a DBCombo in some time. I wrote the original incremental search code for the TDBCombo class but it was since moved into the parent class, TCombobox. I have in my notes that moving the code to TComobox broke it for DBCombo but I don't know if that was ever fixed. It is late now, but I will try to look at it tomorrow.

James


James, no problem, thanks same for replying...greetings...thank you... :-)
Dios no está muerto...



Gracias a mi Dios ante todo!
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Allow a write in Get in a Combobox
Posted: Wed Sep 06, 2017 01:39 PM
Mr Jose,

Incremental search works by default in DbCombo. No additional settings are necessary.
This is a working sample
Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()

   field CODE,NAME
   local oDlg, oCbx
   local cCode

   USE STATES
   INDEX ON CODE TAG CODE
   INDEX ON NAME TAG NAME
   SET ORDER TO TAG NAME
   GO TOP
   cCode    := STATES->CODE

   DEFINE DIALOG oDlg SIZE 400,500 PIXEL TRUEPIXEL

   @ 20,20 DBCOMBO oCbx VAR ccODE SIZE 200,400 PIXEL OF oDlg ;
      ALIAS "STATES" ;
      ITEMFIELD "CODE" ;
      LISTFIELD "NAME"

   ACTIVATE DIALOG oDlg CENTERED

return nil

Note: Though the documentation at the top of the source code of the dbcombo.prg says that the list needs to ordered, incremental search works even with unordered lists.
Regards



G. N. Rao.

Hyderabad, India
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Allow a write in Get in a Combobox
Posted: Wed Sep 06, 2017 03:20 PM
Mr James


but it was since moved into the parent class, TCombobox. I have in my notes that moving the code to TComobox broke it for DBCombo but I don't know if that was ever fixed.

Incremental search is implemented in KeyChar() method. It is the same original method I see in all versions (from 12.04). So, there is no movement of the code or break of code. You may verify the source code of FWH you are using.
Regards



G. N. Rao.

Hyderabad, India
Posts: 2064
Joined: Fri Jan 06, 2006 09:28 PM
Re: Allow a write in Get in a Combobox
Posted: Thu Sep 07, 2017 03:15 AM
nageswaragunupudi wrote:Mr Jose,

Incremental search works by default in DbCombo. No additional settings are necessary.
This is a working sample
Code (fw): Select all Collapse
#include "fivewin.ch"

function Main()

   field CODE,NAME
   local oDlg, oCbx
   local cCode

   USE STATES
   INDEX ON CODE TAG CODE
   INDEX ON NAME TAG NAME
   SET ORDER TO TAG NAME
   GO TOP
   cCode    := STATES->CODE

   DEFINE DIALOG oDlg SIZE 400,500 PIXEL TRUEPIXEL

   @ 20,20 DBCOMBO oCbx VAR ccODE SIZE 200,400 PIXEL OF oDlg ;
      ALIAS "STATES" ;
      ITEMFIELD "CODE" ;
      LISTFIELD "NAME"

   ACTIVATE DIALOG oDlg CENTERED

return nil

Note: Though the documentation at the top of the source code of the dbcombo.prg says that the list needs to ordered, incremental search works even with unordered lists.


Mr.NAGE, in your sample it works but only with the first 2 letters of the word to search, I imagine that it is the field value in the DBF, in my case I use ARRAY to feed the DBCOMBO from a QUERY with mysql, which change dynamically ... with different created querys, and in resource mode defined as DROPDOWN and the sequential search does not work ... I am doing wrong or how should I do it? greetings...thank you... :-)

DEFINICION DEL DBCOMBO
Code (fw): Select all Collapse
   REDEFINE DBCOMBO aGet[1] VAR aVar[1] ID 101 OF oDlg UPDATE ; // OPCIONES BUSQUEDA
      ITEMS aBuscar1 ;
      LIST  aBuscar2 ;
      ON CHANGE ( IIF( aVar[1] == "3" .or. aVar[1] == "4" ,; // SELECTORES
                     ( sel_pax( aVar, aGet ) ) ,  aGet[5]:Disable() ) ,;
      refresget( aGet ), aGet[5]:REFRESH() )



CAMBIO DINAMICO DEL CONTENIDO DEL DBCOMBO
Code (fw): Select all Collapse
PROCEDURE sel_pax( aVar, aGet )

   LOCAL aNuevo1 := {}, aNuevo2 := {}, cSelec, aArray0

   DO CASE
      CASE aVar[1] == "3" // ESTADO CLI.
         cSelec := "- Seleccione Estado -"

         aArray0 := array_tablas( "id_estatus, estatus" ,;
            "tbl_eststus", "id_estatus" )

         aNuevo1 := aArray0[1]; aNuevo2 := aArray0[2]

      CASE aVar[1] == "4" // VENDEDOR
         cSelec := "- Seleccione Vendedor -"

         aArray0 := array_tablas2( {"id_usuario", "apellidos", "nombres"} ,;
            "tbl_usuarios" )

         aNuevo1 := aArray0[1]; aNuevo2 := aArray0[2]
   END CASE

   AAdd( aNuevo1, "0" ); AAdd( aNuevo2, cSelec )

   aGet[5]:aItems := aNuevo1
   aGet[5]:aList  := aNuevo2
   aGet[5]:SetItems( aGet[5]:aItems, aGet[5]:aList, .t. )

   aVar[5] := "0"

   aGet[5]:REFRESH()
RETURN
Dios no está muerto...



Gracias a mi Dios ante todo!
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: Allow a write in Get in a Combobox
Posted: Fri Sep 08, 2017 04:50 PM
in your sample it works but only with the first 2 letters of the word to search,

Please test again. It works for more than 2 characters also, provided it finds a match.

I shall soon give you an example of dynamically changing the items
Regards



G. N. Rao.

Hyderabad, India

Continue the discussion