Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Move code from Refresh method to CustomRefresh()
Message
 
 
To
10/09/2018 10:45:16
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
01661889
Message ID:
01661931
Views:
36
>>>>>>Hi,
>>>>>>
>>>>>>I have a general question about the following situation. Just to see if anybody thinks it is a good or a bad practice. Or sees any gotchas with this approach.
>>>>>>
>>>>>>I have a textbox class that shows the value of the ID (unique field) from a lookup (parent) table, based on the PK value in the child table. The code that uses the Seek() the lookup (parent) table and sets the value of the ID (or unique field) is in the Refresh method of this textbox. This approach works. But ... The Refresh of the textbox fires quite often. Any time another window/form is open and then the focus is returned back to this form, the Refresh fires. I would like to reduce the calls to the Refresh field.
>>>>>>
>>>>>>So, my approach, is to create a custom refresh method (e.g. CustomRefresh), move the code from the Refresh to the CustomRefresh. Then call the textbox CustomRefresh from a method of a form, whenever a record moves. Therefore, the code in CustomRefresh will not be fired unnecessarily often but only when is necessary, when record pointer moves.
>>>>>>
>>>>>>Does the above seem like a reasonable approach?
>>>>>
>>>>>Sounds like you should have a form method called SetParentID, which is a reasonable name for the task you are performing.
>>>>
>>>>The name is not important (IMO) but your message confirms my approach of having form method calling a method of a textbox is reasonable.
>>>
>>>Agreed.
>>
>>Yes, we are in agreement on that. But the my starting this process was caused by thinking that the Refresh method of a textbox is called every time the form goes into focus. But Christian Isberner said it does not work that way. And so, far, when I am testing in a newly created form, he is right. I don't see a textbox Refresh fired every time the test form goes into focus. So, it must be something in my project form that causes the Refresh being fired. And I have not had a chance yet to spend time to figure out what fires textbox(s) Refresh in my program.
>
>Set a breakpoint in the refresh method, and check the call stack.

Thank you. I will do that.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham
Previous
Reply
Map
View

Click here to load this message in the networking platform