Hola,
mira este codigo, de esta manera lo hice
Code: Select all
REDEFINE BMPGET oGet VAR cResponsable ID 102 OF oDlg BCOLOR CLR_BLACK, CLR_YELLOW ;
UPDATE WHEN ! job $ "anul,del,view,anul";
PICTURE "@!"
oGet:bPostKey := {|oGet, cBuffer| setResponsable( oget ) }
//------------------------------------------------------------------------------
FUNCTION setResponsable( oGet )
//------------------------------------------------------------------------------
LOCAL nPosItem := 0 // Text position into ::aItems
LOCAL nPosCursor := oGet:nPos // Current cursor position
LOCAL nLength := LEN(oGet:cText) // Text length
LOCAL cStartTxt := LEFT(oGet:cText, nPosCursor-1) // Start text (position 1 to cursor position -1)
LOCAL cItem := ""
LOCAL nKey := 0
nKey := oGet:nLastKey
DO CASE
CASE nKey == VK_TAB .or. ;
nKey == VK_RETURN .or. ;
nKey == VK_DELETE
oGet:Assign() // Assign typed text
CASE nKey >= 32 .And. nKey <= 256
responsables -> ( DBEXIST( cStartTxt, "nombre", .T. ) )
cItem := responsables -> nombre
IF LEFT( cItem, LEN(cStartTxt) ) = cStartTxt
nLength := LEN( RTRIM( cItem ) )
cItem += SPACE( nLength - LEN(cItem) )
oGet:SetText( cItem )
oGet:SetSel( nPosCursor -1, nLength) // Select found text
oGet:oGet:Buffer = PAD( cItem, LEN( oGet:oGet:Buffer ))
RETURN(.t.)
ENDIF
oGet:HideSel() // Text not found -> Undo selected text
ENDCASE
RETURN( .T. )
El DBEXIST es una funcion propia, pudes reemplazarla por un DBSEEK. Si te das cuenta esto es parte de la clase de Maurilio, entonces esa misma clase podrias modificarla para que en lugar de utilizar arrays puedas utilizar una tabla, claro que la idea es que se parametrice para generalizar
Espero te ayude.
saludos
Marcelo