Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Grid empty after TableRevert(.f.)
Message
 
 
À
02/11/2001 07:56:11
Information générale
Forum:
Visual FoxPro
Catégorie:
Classes - VCX
Divers
Thread ID:
00576215
Message ID:
00576709
Vues:
18
Hi!

You can use getfldstate(-1) and check if all characters there contain "3":

if chrtran(getfldstate(-1),"3","")==""
* this record is new but contains no data
* tablerevert it:
...
endif

So in AfterRowColChange you check if reccount() is changed (to see if new record added), if yes - store current record pointer and go to previous record, check previous record if it is completely empty or whatever and revert changes in it, then go back to new created record.

As about "empty" grid - after all changes in the record source for grid you have to use "Grid.Refresh" method call to refresh grid after such changes. This include tablerevert() as well. Let me know if this helped...

>Vlad,
>
>The reason I'm using table buffering is because I have a toolbar on the form with save & undo buttons, and I dont want those buttons to be enabled if nothing has changed. I also want to give the user the ability to undo all changes.
>
>So my _textbox class and all other editable subclassed controls run method CheckChanges()in the VALID method, which cycles through the forms dataenvironment and checks for changes.
>
>This then calls method ThisForm.SetActiveObjects which enables or disables controls.
>It works, too.
>
>In the case of the empty value & tablerevert(.f.), I only revert that one record, not all the others.
>
>Lastkey() will tell me if the user pressed the downarrow, but that's not what I need, 'cause in a grid the user can press downarrow plenty of times, without it meaning he has added a new record.
>
>Whether the record is new or not is not the issue, it's the state of one certain field that's interresting, that field just has to be filled, and can not be filled by some default value. Also, although its not an ID, there may not be duplicate values for that one field.
>Finally, I don't want to lock the user in that field by returning 0 if the value is not correct.
>
>I have noticed, that when I press the UpArrow on an empty record, the grid does not empty, and I'm now trying out a KeyBoard '{UpArrow}'. I'll let you know how I fare.
>
>>Hi!
>>
>>1. Just use LastKey() to see if new record added and disallow revert. You can also use GetFldState() to check if field state is "3" - in such case field is marked as new, but not changed - and allow leaving field too.
>>
>>2. What you going to organize in general? I'm confused by using the tablerevert() inside of the field value. Assume user enters 2 values, forget to enter third value and tabbed. 2 previous values will be cleared by tablerevert(). Quite confusing.
>>I assume you want to check if used leaves new record without any changes, right? For such case, use AfterRowColChange event - store current recno() in the code in this event. Store it in some property (grid class or form property). When it is changed, then check if you need to do tablerevert().
>>
>>3. Do not know why tablerevert() cause grid becomes empty. Can you go step by step in debugger through running code and see what command exactly cause this behaviour? Did you tried "Grid.Refresh" command after tablerevert()?
>>
>>Tell also what buffering (row or table) is used for view.
>>
>>>It's an indexed view with Tablebuffering set to 5 in a grid with AllowAddNew=.T.
>>>
>>>In the Valid method of a field in the grid, if said field is empty or a seek() has found a similar value with a lower RECNO(), I execute the following code:
>>>
>>>
>>>IF EMPTY(THIS.VALUE)
>>>  llRetval=TABLEREVERT(.F.)
>>>ELSE
>>>  lnRecno=RECNO("ActiveMembers")
>>>  IF SEEK(ALLTRIM(THIS.VALUE),"ActiveMembers","Member");
>>>     AND RECNO("ActiveMembers")# lnRecno
>>>     GO lnRecno IN ActiveMembers
>>>     llRetval=TABLEREVERT(.F.)
>>>  ENDIF
>>>ENDIF
>>>
>>>This does not work quite as I expected.
>>>For one, if I add a record by downarrow, it never makes it. Valid fires and finds the value empty and reverts the table.
>>>
>>>If I click a button on the form it works, though.
>>>
>>>But in any case, if the TableRevert(.f.) is issued, the grid is emptied of records.
>>>I have tried going top in the view, but that does not help.
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform