Page 1 of 1

Allow a write in Get in a Combobox

PostPosted: Sat Sep 02, 2017 7:50 pm
by Rick Lipkin
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

Image

Re: Allow a write in Get in a Combobox

PostPosted: Sat Sep 02, 2017 8:24 pm
by Enrico Maria Giordano
Give style CBS_DROPDOWN to the combobox.

EMG

Re: Allow a write in Get in a Combobox

PostPosted: Mon Sep 04, 2017 3:50 pm
by Rick Lipkin
Enrico

Worked Great ... Many Thanks!

Rick Lipkin

Re: Allow a write in Get in a Combobox

PostPosted: Mon Sep 04, 2017 7:24 pm
by joseluisysturiz
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:

Re: Allow a write in Get in a Combobox

PostPosted: Mon Sep 04, 2017 10:33 pm
by James Bott
Jose,

You must set oDB:incSearch := .t.

The default is .f.

Re: Allow a write in Get in a Combobox

PostPosted: Mon Sep 04, 2017 11:36 pm
by joseluisysturiz
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... :shock:

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... :shock:

Code: Select all  Expand view

   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 )

Re: Allow a write in Get in a Combobox

PostPosted: Tue Sep 05, 2017 5:37 am
by James Bott
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

Re: Allow a write in Get in a Combobox

PostPosted: Tue Sep 05, 2017 10:46 pm
by joseluisysturiz
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... :shock:

Re: Allow a write in Get in a Combobox

PostPosted: Wed Sep 06, 2017 1:39 pm
by nageswaragunupudi
Mr Jose,

Incremental search works by default in DbCombo. No additional settings are necessary.
This is a working sample
Code: Select all  Expand view

#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.

Re: Allow a write in Get in a Combobox

PostPosted: Wed Sep 06, 2017 3:20 pm
by nageswaragunupudi
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.

Re: Allow a write in Get in a Combobox

PostPosted: Thu Sep 07, 2017 3:15 am
by joseluisysturiz
nageswaragunupudi wrote:Mr Jose,

Incremental search works by default in DbCombo. No additional settings are necessary.
This is a working sample
Code: Select all  Expand view

#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... :shock:

DEFINICION DEL DBCOMBO
Code: Select all  Expand view

   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: Select all  Expand view

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
 

Re: Allow a write in Get in a Combobox

PostPosted: Fri Sep 08, 2017 4:50 pm
by nageswaragunupudi
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