These are some changes that I made to the INGRID class to enhance it. I hope it help you...
**************************************************
*-- Class: ingrid (c:\points\libs\jdsoft.vcx)
*-- ParentClass: textbox
*-- BaseClass: textbox
*-- InGrid: Incremental Grid class.
*
DEFINE CLASS ingrid AS textbox
Height = 24
ReadOnly = .T.
SpecialEffect = 0
ToolTipText = ""
Width = 113
Style = 0
*-- [cHoldCaption]: Hold column caption so that it can be restored.
PROTECTED choldcaption
choldcaption = ""
*-- [nHoldRecord]: Hold/restore the current record in case the seek fails.
PROTECTED nholdrecord
nholdrecord = 0
*-- lInGridActive: Flag to activate/deactivate incremental grid keystroke trapping.
lingridactive = .T.
*-- cOrderTag: Index tag to control display order while on current column (leave blank to use current tag).
cordertag = ""
*-- lSearchPreview: Flag to activate/deactivate incremental grid keystroke preview in column caption.
lsearchpreview = .T.
*-- cSeekTag: Index tag to seek against with SearchString (leave blank to use cOrderTag or current tag).
cseektag = ""
*-- [cSearchString]: Search string to seek record with.
PROTECTED csearchstring
csearchstring = ""
*-- [nLastPress]: Last time a key was pressed.
PROTECTED nlastpress
nlastpress = 0
*-- cLocateExpression: Locate expression to match against with SearchString (Use this setting if no index tags are available to seek against).
clocateexpression = ""
Name = "ingrid"
*-- [lSeekMode]: Flag to suppress GotFocus/LostFocus behavior during seek operations.
PROTECTED lseekmode
*-- [KeySeek]: InGrid seek method.
PROTECTED PROCEDURE keyseek
**
** InGrid KeySeek method
**
LOCAL cHoldAlias, ;
cHoldTag, moldnear
m.cHoldAlias = ALIAS()
SELECT (THIS.Parent.Parent.RecordSource)
IF !EMPTY(THIS.cLocateExpression)
GO TOP
LOCATE FOR EVAL(THIS.cLocateExpression) = THIS.cSearchString
ELSE
IF !EMPTY(THIS.cSeekTag)
m.cHoldTag = ORDER()
SET ORDER TO THIS.cSeekTag
ENDIF
moldnear=SET('NEAR')
SET NEAR ON
SEEK (UPPER(THIS.cSearchString))
set near &moldnear
ENDIF
IF FOUND()
IF THIS.nHoldRecord#RECNO()
THIS.lSeekMode=.T.
ENDIF
ELSE
IF !EMPTY(THIS.cLocateExpression)
GO THIS.nHoldRecord
ELSE
IF EOF()
GO THIS.nHoldRecord
ENDIF
IF THIS.nHoldRecord#RECNO()
THIS.lSeekMode=.T.
ENDIF
ENDIF
ENDIF
IF !EMPTY(THIS.cSeekTag)
SET ORDER TO m.cHoldTag
ENDIF
IF THIS.lSearchPreview
THIS.Parent.Header1.Caption = THIS.cSearchString
ENDIF
IF USED(m.cHoldAlias)
SELECT (m.cHoldAlias)
ENDIF
ENDPROC
PROCEDURE KeyPress
LPARAMETERS nKeyCode, nShiftAltCtrl
PRIVATE m.nElapsedTime
IF THIS.lInGridActive
THIS.nHoldRecord = RECNO()
m.nElapsedTime = SECONDS()-THIS.nLastPress
DO CASE
CASE BETWEEN(m.nKeyCode, 48, 126) OR INLIST(m.nKeyCode,32,45,39,48) && AlphaNumeric
NODEFAULT
IF m.nElapsedTime<(_DBLCLICK+1)
THIS.cSearchString= THIS.cSearchString+ UPPER(CHR(m.nKeyCode))
ELSE
THIS.Parent.Header1.Caption=THIS.cHoldCaption
THIS.cSearchString= UPPER(CHR(m.nKeyCode))
ENDIF
THIS.KeySeek
THIS.nLastPress=SECONDS()
CASE m.nKeyCode=13 && Enter Key
NODEFAULT
IF ! empty(THIS.cSearchString)
THIS.KeySeek
ENDIF
THIS.cSearchString = ""
THIS.Parent.Header1.Caption=THIS.cHoldCaption
THIS.nLastPress=SECONDS()
CASE m.nKeyCode=27 && Esc Key
THIS.cSearchString = ""
THIS.KeySeek
THIS.Parent.Header1.Caption=THIS.cHoldCaption
THIS.nLastPress=SECONDS()
CASE m.nKeyCode=127 .or. m.nKeyCode=7 && Backspace or del
NODEFAULT
IF LEN(THIS.cSearchString)<1
THIS.cSearchString = ""
IF SET("BELL")="ON"
?? CHR(7)
ENDIF
ELSE
THIS.cSearchString=LEFT(THIS.cSearchString, ;
LEN(THIS.cSearchString)-1)
THIS.KeySeek
ENDIF
THIS.nLastPress=SECONDS()
OTHERWISE
IF THIS.lSearchPreview
THIS.PARENT.Header1.CAPTION=THIS.cHoldCaption
ENDIF
ENDCASE
ENDIF
ENDPROC
PROCEDURE LostFocus
IF THIS.lInGridActive
IF !THIS.lSeekMode AND THIS.lSearchPreview
THIS.Parent.Header1.Caption = THIS.cHoldCaption
THIS.cSearchString=""
ENDIF
ENDIF
ENDPROC
PROCEDURE GotFocus
LOCAL cHoldAlias
IF THIS.lInGridActive
IF THIS.lSeekMode
THIS.lSeekMode = .F.
ELSE
IF THIS.lSearchPreview
THIS.cHoldCaption = THIS.Parent.Header1.Caption
ENDIF
IF EMPTY(THIS.cLocateExpression) AND !EMPTY(THIS.cOrderTag)
m.cHoldAlias = ALIAS()
SELECT (THIS.Parent.Parent.RecordSource)
SET ORDER TO THIS.cOrderTag
THISFORM.REFRESH()
SELECT (m.cHoldAlias)
ENDIF
THIS.cSearchString=""
ENDIF
ENDIF
ENDPROC
ENDDEFINE
*
*-- EndDefine: ingrid
**************************************************
Previous
Reply
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only