Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid Control - Append a new record in the last grid row
Message
De
11/11/1998 03:23:38
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
10/11/1998 16:32:20
Information générale
Forum:
Visual FoxPro
Catégorie:
Gestionnaire d'écran & Écrans
Divers
Thread ID:
00156026
Message ID:
00156503
Vues:
40
>>>
>>>how about
>>>
>>>IF RECCOUNT(THIS.RecordSource) = 0
>>
>>RECCOUNT ignores SET DELETED status so if I deleted a child record, RECCOUNT will always come back with at least 1.
>
>Ok, still trying here...
>
>IF EOF(THIS.RecordSource) OR BOF(THIS.RecordSource) OR DELETED(THIS.RecordSource)
>    GO TOP IN (This.RecordSource)
>    IF EOF(THIS.RecordSource)
>       APPEND BLANK IN (THIS.RecordSource)
>    ENDIF
>ENDIF
>
Hi all,
Well while I succeeded to have a line to UT here is my 2 cents about this subject:)
Reccount() doesn't help, because this could be a child grid, a filter might be in effect, set deleted might be on etc. And activerow in when, valid always returns 0 :(
IMHO eof(this.recordsource) in when of grid is the way to go. I would change the code a little bit though
IF EOF(THIS.RecordSource)
  APPEND BLANK IN (THIS.RecordSource)
ENDIF
this.refresh && Strange - but needed if grid getsfocus with click
If table is buffered appending a new row is not dangerous and simply could be reverted in valid of grid. Adding code in beforerowcolchange and valid to check for row validation makes this a good way for using allowaddnew=.t. Plus a sequence like this provide another keycombination to be used to add records (I use Ctrl+DnArrow) so user doesn't need to scroll down to last record:
*Afterrowcolchange
.allowaddnew = .f.
if lastkey() = 145 and this.lRowValidated() && lRowValidated checks row validation
  go bottom in (.recordsource)
  .allowaddnew = .t.
  keyboard "{DNARROW}"
  .refresh
endif
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform