main logo
Subject: Code for a Simple Dataentry grid
Author: Mike Devlin
Posted: 2001/09/19 16:35:04
 
View Entire Thread
New Search


I have put a little code in the securegrid to make it add records to the child view when the user presses the down arrow or clicks in the grid. If anyone can help, please add this to the grid and break it and then let me know where it broke.
TIA =)

**********************************************************
Grid.click
** This method needs to be copied and overwritten in any subclass, if the
** records being added have default value that should be set.

=DODEFAULT()

This.SetFocus() && This method removes the focus from any of the contained
&& controls and puts the focus on the grid. It also makes
&& the ActiveRow = 0.
This.lsuppressrowcolchange = .T. && This kills any code that would normally be performed in the
&& AfterRowColChange() event.
APPEND BLANK IN (This.RecordSource)

* Any default values that should be automatically inserted into the new record should set here

This.Refresh()
**********************************************************
**********************************************************
Grid.AfterRowColChange()
** This method needs to be copied and overwritten in any subclass, if the
** records being added have default value that should be set.

LPARAMETERS nColIndex

IF !This.lSuppressRowColChange
IF (RECNO() < 0) ; && A record is being inserted if RECNO() returns a negative number.
AND (This.lAdding) && This is a flag property set in the beforerowcolchange
** This is the place to put any default values for the newly added record.
ENDIF
ENDIF

This.Refresh()
This.lSuppressRowColChange = .F.
**********************************************************
**********************************************************
Grid.BeforeRowColChange()
LPARAMETERS nColIndex

* If the grid is adding a new record to the grid's RecordSource, the ActiveRow property is 0.
IF (This.ActiveRow == 0) && Tabbing into the grid does not call the beforerowcolchange event.
This.lAdding = .T.
ELSE
This.lAdding = .F.
ENDIF
**********************************************************
Devman
mdevlin At ajdebruin .DOT com

 
©2001 Mike Devlin
<-- Prior Message New Search Next Message -->