Allow a write in Get in a Combobox

Allow a write in Get in a Combobox

Postby Rick Lipkin » Sat Sep 02, 2017 7: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

Image
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Allow a write in Get in a Combobox

Postby Enrico Maria Giordano » Sat Sep 02, 2017 8:24 pm

Give style CBS_DROPDOWN to the combobox.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8710
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: Allow a write in Get in a Combobox

Postby Rick Lipkin » Mon Sep 04, 2017 3:50 pm

Enrico

Worked Great ... Many Thanks!

Rick Lipkin
User avatar
Rick Lipkin
 
Posts: 2663
Joined: Fri Oct 07, 2005 1:50 pm
Location: Columbia, South Carolina USA

Re: Allow a write in Get in a Combobox

Postby joseluisysturiz » Mon Sep 04, 2017 7: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!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: Allow a write in Get in a Combobox

Postby James Bott » 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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Allow a write in Get in a Combobox

Postby joseluisysturiz » 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... :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 )
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: Allow a write in Get in a Combobox

Postby James Bott » Tue Sep 05, 2017 5: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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: Allow a write in Get in a Combobox

Postby joseluisysturiz » 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... :shock:
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: Allow a write in Get in a Combobox

Postby nageswaragunupudi » Wed Sep 06, 2017 1:39 pm

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

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Allow a write in Get in a Combobox

Postby nageswaragunupudi » Wed Sep 06, 2017 3: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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Allow a write in Get in a Combobox

Postby joseluisysturiz » Thu Sep 07, 2017 3:15 am

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
 
Dios no está muerto...

Gracias a mi Dios ante todo!
User avatar
joseluisysturiz
 
Posts: 2064
Joined: Fri Jan 06, 2006 9:28 pm
Location: Guatire - Caracas - Venezuela

Re: Allow a write in Get in a Combobox

Postby nageswaragunupudi » Fri Sep 08, 2017 4: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
User avatar
nageswaragunupudi
 
Posts: 10620
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 32 guests