Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Maintaining Grid Row after Editing 3

Status
Not open for further replies.

David Higgs

Programmer
May 6, 2012
392
GB
In my application when I click on a Row in my Grid the entire Row is Highlighted. Double Clicking on the Highlighted Row opens up a Form which allows Editing of the selected Record. When this form is closed irrespective of any changes to the data, the Grid ActiveRow always defaults to the last record. What do I need to do to keep the ActiveRow the same as before editing?



Regards,

David.

Recreational user of VFP.
 
Olaf Doschke said:
Fine to see the debugging helped. It could take very long to identify that, if not simply going through what happens in single step mode.

I must admit when I used Debugger for stepping through my Code I thought I wasn't going to find the problem and the next step it was there staring at me in my face.

Thank you for your help and patience, much appreciated.

Regards,

David.

Recreational user of VFP.
 
TamarGranor said:
If you'd like to learn more about how to use the Debugger, check out my paper

Tamar, thank you for the link, most helpful.

Regards,

David.

Recreational user of VFP.
 
TamarGranor said:
You'll find lots more at:

Many thanks Tamar, that'll keep me occupied for a while!

Regards,

David.

Recreational user of VFP.
 
From event order perspective you now know initially what runs is:

Load
Init
Show
Activate

LISA

Also, activate is repeated every time the form is getting focus. Therefore anything you only want to be done once better goes into init, not activate.
There are good reasons to put things into the Activate event as the best moment, but Init is not, as one would expect, too early. It's not running first. First, all control Inits are running, so in Form.Init you already have access to all form controls, they're yet not shown, but already there.

It's a good idea to extend the event model in the way you can: Let the Form.Init call a user-defined Form.reinit method, that'll then also only run once, but you could rerun things, whenever you want to trigger a form reinitialization, and that could skip things, which only should run once, that you keep in init.

Likewise, you may define a Form.Firstactivate() and call that from Form.Activate(). Add a form property Form.isactivated initially false and then only call Thisform.Firstactivate() if that's still false and set it true.

Such things give you more control. You can't make any user-defined method an event, but calling them from events you make it a two-part event, of which you may run one part whenever you want, not only in that event. Another good example is a user-defined ControlChange() method you let be called from both ProgrammaticChange and InteractiveChange, for things, that should happen in both cases. You don't want to repeat yourself.

Bye, Olaf.

Olaf Doschke Software Engineering
 
Olaf,

Thank you for your excellent post. LISA, I like that, I'll keep reciting it until it sinks in!

Regards,

David.

Recreational user of VFP.
 
I've always encountered that as LISA G, where the G stands for GotFocus of the first control.

Tamar
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top