Textbox in grid column question.... When is the value entered in a textbox in a grid column applied to the underlying bound cursor relative to the firing of the grid.AfterRowColChange() when user hits tab to move to the next column?
Here is the situation I am struggling to understand: When entering a new value in a column and then hitting tab to go to the next column, it appears that the value from the textbox which you are exiting is not applied to the cursor yet at the time AfterRowColChange() fires. I have some calculation logic on AfterRowColChange() and the old value is what I am seeing.
As a hack, I have gone this route, but I hate it: In order to get the value from the textbox in the cursor soon enough to be seen by the AfterRowColChange() method code, I have put explicit code in the textbox.Valid() to say “Replace {field} with This.Value in {lcCursor}” and then the cursor is updated so that when AfterRowColChange() is called, it will see the new value in the row for that field.
Am I making any sense with this explanation? What am I missing?
Have you tried using the VFP event log to see what the order of events is, Matt?
--
rk
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Matt Slay Sent: Monday, September 25, 2017 10:56 AM To: profoxtech@leafe.com Subject: Textbox in grid column.... When is cursor updated?
Textbox in grid column question.... When is the value entered in a textbox in a grid column applied to the underlying bound cursor relative to the firing of the grid.AfterRowColChange() when user hits tab to move to the next column?
Here is the situation I am struggling to understand: When entering a new value in a column and then hitting tab to go to the next column, it appears that the value from the textbox which you are exiting is not applied to the cursor yet at the time AfterRowColChange() fires. I have some calculation logic on AfterRowColChange() and the old value is what I am seeing.
As a hack, I have gone this route, but I hate it: In order to get the value from the textbox in the cursor soon enough to be seen by the AfterRowColChange() method code, I have put explicit code in the textbox.Valid() to say “Replace {field} with This.Value in {lcCursor}” and then the cursor is updated so that when AfterRowColChange() is called, it will see the new value in the row for that field.
Am I making any sense with this explanation? What am I missing?
On 25/09/2017 15:55, Matt Slay wrote:
Textbox in grid column question.... When is the value entered in a textbox in a grid column applied to the underlying bound cursor relative to the firing of the grid.AfterRowColChange() when user hits tab to move to the next column?
Here is the situation I am struggling to understand: When entering a new value in a column and then hitting tab to go to the next column, it appears that the value from the textbox which you are exiting is not applied to the cursor yet at the time AfterRowColChange() fires. I have some calculation logic on AfterRowColChange() and the old value is what I am seeing.
As a hack, I have gone this route, but I hate it: In order to get the value from the textbox in the cursor soon enough to be seen by the AfterRowColChange() method code, I have put explicit code in the textbox.Valid() to say “Replace {field} with This.Value in {lcCursor}” and then the cursor is updated so that when AfterRowColChange() is called, it will see the new value in the row for that field.
Am I making any sense with this explanation? What am I missing?
What is the controlsource for the textbox set to?
Peter
This communication is intended for the person or organisation to whom it is addressed. The contents are confidential and may be protected in law. Unauthorised use, copying or disclosure of any of it may be unlawful. If you have received this message in error, please notify us immediately by telephone or email.
www.whisperingsmith.com
Whispering Smith Ltd Head Office:61 Great Ducie Street, Manchester M3 1RR. Tel:0161 831 3700 Fax:0161 831 3715
London Office:17-19 Foley Street, London W1W 6DW Tel:0207 299 7960
/>> //What is the controlsource for the textbox set to? /
controlsource of the column is: "csrPartTasks.Setup"
textbox inherits same control source.
*Matt Slay*
On 09/25/17 9:53 AM, Peter Cushing wrote:
On 25/09/2017 15:55, Matt Slay wrote:
Textbox in grid column question.... When is the value entered in a textbox in a grid column applied to the underlying bound cursor relative to the firing of the grid.AfterRowColChange() when user hits tab to move to the next column?
Here is the situation I am struggling to understand: When entering a new value in a column and then hitting tab to go to the next column, it appears that the value from the textbox which you are exiting is not applied to the cursor yet at the time AfterRowColChange() fires. I have some calculation logic on AfterRowColChange() and the old value is what I am seeing.
As a hack, I have gone this route, but I hate it: In order to get the value from the textbox in the cursor soon enough to be seen by the AfterRowColChange() method code, I have put explicit code in the textbox.Valid() to say “Replace {field} with This.Value in {lcCursor}” and then the cursor is updated so that when AfterRowColChange() is called, it will see the new value in the row for that field.
Am I making any sense with this explanation? What am I missing?
What is the controlsource for the textbox set to?
Peter
This communication is intended for the person or organisation to whom it is addressed. The contents are confidential and may be protected in law. Unauthorised use, copying or disclosure of any of it may be unlawful. If you have received this message in error, please notify us immediately by telephone or email. www.whisperingsmith.com
Whispering Smith Ltd Head Office:61 Great Ducie Street, Manchester M3 1RR. Tel:0161 831 3700 Fax:0161 831 3715 London Office:17-19 Foley Street, London W1W 6DW Tel:0207 299 7960
[excessive quoting removed by server]
On 25/09/2017 16:04, Matt Slay wrote:
/>> //What is the controlsource for the textbox set to? /
controlsource of the column is: "csrPartTasks.Setup"
textbox inherits same control source.
I have a screen where the user can enter values in a grid and I call a function thisform.sumrows called from grid.AfterRowColChange(). This just saves the record number and sums up the values and displays the result in a textbox below the grid. Never had a problem with a value missing. It could be as others have said that moving off the current record updates the cursor.
Peter
This communication is intended for the person or organisation to whom it is addressed. The contents are confidential and may be protected in law. Unauthorised use, copying or disclosure of any of it may be unlawful. If you have received this message in error, please notify us immediately by telephone or email.
www.whisperingsmith.com
Whispering Smith Ltd Head Office:61 Great Ducie Street, Manchester M3 1RR. Tel:0161 831 3700 Fax:0161 831 3715
London Office:17-19 Foley Street, London W1W 6DW Tel:0207 299 7960
It could be as others have said that moving off the current record
updates the cursor.
I have confirmed that if I use the down arrow to exit the textbox and move to the next *row* in the grid, the calculations in AfterRowColChange() work perfectly, so that shows that the value from the textbox is applied to the cursor beforehand when changing rows. But, when moving horizontally from one column to another, I have to move *2* columns before the calculations based on the underlying cursor work properly.
*Matt Slay*, President Jordan Machine Co. 355 Clow Lane PO Box 170339 Birmingham, AL 35217 Ph: 205-849-5050 Fx: 205-849-5075 mattslay@jordanmachine.com mailto:mattslay@jordanmachine.com http://www.JordanMachine.com
On 09/25/17 10:48 AM, Peter Cushing wrote:
On 25/09/2017 16:04, Matt Slay wrote:
/>> //What is the controlsource for the textbox set to? /
controlsource of the column is: "csrPartTasks.Setup"
textbox inherits same control source.
I have a screen where the user can enter values in a grid and I call a function thisform.sumrows called from grid.AfterRowColChange(). This just saves the record number and sums up the values and displays the result in a textbox below the grid. Never had a problem with a value missing. It could be as others have said that moving off the current record updates the cursor.
Peter
This communication is intended for the person or organisation to whom it is addressed. The contents are confidential and may be protected in law. Unauthorised use, copying or disclosure of any of it may be unlawful. If you have received this message in error, please notify us immediately by telephone or email. www.whisperingsmith.com
Whispering Smith Ltd Head Office:61 Great Ducie Street, Manchester M3 1RR. Tel:0161 831 3700 Fax:0161 831 3715 London Office:17-19 Foley Street, London W1W 6DW Tel:0207 299 7960
[excessive quoting removed by server]
Some other thoughts. Is this cursor inside a transaction? If so, what kind of buffering do you have set? If you are row buffered and moving from column to column in your grid, no implicit replace or update operation will happen unless you move the record pointer, right?
--
rk
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Matt Slay Sent: Monday, September 25, 2017 10:56 AM To: profoxtech@leafe.com Subject: Textbox in grid column.... When is cursor updated?
Textbox in grid column question.... When is the value entered in a textbox in a grid column applied to the underlying bound cursor relative to the firing of the grid.AfterRowColChange() when user hits tab to move to the next column?
Here is the situation I am struggling to understand: When entering a new value in a column and then hitting tab to go to the next column, it appears that the value from the textbox which you are exiting is not applied to the cursor yet at the time AfterRowColChange() fires. I have some calculation logic on AfterRowColChange() and the old value is what I am seeing.
As a hack, I have gone this route, but I hate it: In order to get the value from the textbox in the cursor soon enough to be seen by the AfterRowColChange() method code, I have put explicit code in the textbox.Valid() to say “Replace {field} with This.Value in {lcCursor}” and then the cursor is updated so that when AfterRowColChange() is called, it will see the new value in the row for that field.
Am I making any sense with this explanation? What am I missing?
No buffering is involved.
In fact, if you tab over two columns, you finally get the expected calculated value from the logic in the AfterRowColChange() method. I see why... The first column move the method does not the new values, but once that move is complete, then the value in the cursor is updated, so that when you move a second time, it then has the new value so the calculation works correctly. However, I cannot let my user experience this odd latency.
BTW - The calculate in the AfterRowColChange updates a property on a data object and that property is displayed in another read-only textbox outside of the grid. So, when they user enters a new value in the grid column, and tabs over, they expect to see the other textbox update to show the new calculated value from their data entry in the grid.
Here is basically the code that gets fired in AfterRowColChange():
Procedure AfterRowColChange()
Thisform.oBusinessObject.UpdatePropertiesFromGridCursor()
Thisform.Refresh()
EndProc
*Matt Slay*
On 09/25/17 10:07 AM, Richard Kaye wrote:
Some other thoughts. Is this cursor inside a transaction? If so, what kind of buffering do you have set? If you are row buffered and moving from column to column in your grid, no implicit replace or update operation will happen unless you move the record pointer, right?
--
rk
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Matt Slay Sent: Monday, September 25, 2017 10:56 AM To: profoxtech@leafe.com Subject: Textbox in grid column.... When is cursor updated?
Textbox in grid column question.... When is the value entered in a textbox in a grid column applied to the underlying bound cursor relative to the firing of the grid.AfterRowColChange() when user hits tab to move to the next column?
Here is the situation I am struggling to understand: When entering a new value in a column and then hitting tab to go to the next column, it appears that the value from the textbox which you are exiting is not applied to the cursor yet at the time AfterRowColChange() fires. I have some calculation logic on AfterRowColChange() and the old value is what I am seeing.
As a hack, I have gone this route, but I hate it: In order to get the value from the textbox in the cursor soon enough to be seen by the AfterRowColChange() method code, I have put explicit code in the textbox.Valid() to say “Replace {field} with This.Value in {lcCursor}” and then the cursor is updated so that when AfterRowColChange() is called, it will see the new value in the row for that field.
Am I making any sense with this explanation? What am I missing?
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html ---
Matt,
It does not exactly reply to your question. Please consider NOT to update / edit a textbox in a grid, use instead a textbox outside the grid. To be sure your textbox is updated, when txtbox ControlSourse is a cursor apply the 'safeselect' procedure as developped by Andy Kramek. This works 100% always. Regards, Koen
2017-09-25 17:29 GMT+02:00 Matt Slay mattslay@jordanmachine.com:
No buffering is involved.
In fact, if you tab over two columns, you finally get the expected calculated value from the logic in the AfterRowColChange() method. I see why... The first column move the method does not the new values, but once that move is complete, then the value in the cursor is updated, so that when you move a second time, it then has the new value so the calculation works correctly. However, I cannot let my user experience this odd latency.
BTW - The calculate in the AfterRowColChange updates a property on a data object and that property is displayed in another read-only textbox outside of the grid. So, when they user enters a new value in the grid column, and tabs over, they expect to see the other textbox update to show the new calculated value from their data entry in the grid.
Here is basically the code that gets fired in AfterRowColChange():
Procedure AfterRowColChange()
Thisform.oBusinessObject.UpdatePropertiesFromGridCursor() Thisform.Refresh()EndProc
*Matt Slay*
On 09/25/17 10:07 AM, Richard Kaye wrote:
Some other thoughts. Is this cursor inside a transaction? If so, what kind of buffering do you have set? If you are row buffered and moving from column to column in your grid, no implicit replace or update operation will happen unless you move the record pointer, right?
--
rk
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Matt Slay Sent: Monday, September 25, 2017 10:56 AM To: profoxtech@leafe.com Subject: Textbox in grid column.... When is cursor updated?
Textbox in grid column question.... When is the value entered in a textbox in a grid column applied to the underlying bound cursor relative to the firing of the grid.AfterRowColChange() when user hits tab to move to the next column?
Here is the situation I am struggling to understand: When entering a new value in a column and then hitting tab to go to the next column, it appears that the value from the textbox which you are exiting is not applied to the cursor yet at the time AfterRowColChange() fires. I have some calculation logic on AfterRowColChange() and the old value is what I am seeing.
As a hack, I have gone this route, but I hate it: In order to get the value from the textbox in the cursor soon enough to be seen by the AfterRowColChange() method code, I have put explicit code in the textbox.Valid() to say “Replace {field} with This.Value in {lcCursor}” and then the cursor is updated so that when AfterRowColChange() is called, it will see the new value in the row for that field.
Am I making any sense with this explanation? What am I missing?
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]
Matt, +1 for Koen's comment re safeselect.
I have a standard rule about never updating fields in a grid in situ unless they are straight lookup fields where there is no inter dependency between fields. The effects of changing tab order and also the possibility of simply hitting "ESC" or releasing the form immediately can have weird effects on any dependent calculations. Giving explicit focus to a field outside the grid means you can be sure that all data validation is completed before the record pointer is changed.
Dave
-----Original Message----- From: ProFox [mailto:profox-bounces@leafe.com] On Behalf Of Koen Piller Sent: 25 September 2017 16:27 To: ProFox Email List profox@leafe.com Subject: Re: Textbox in grid column.... When is cursor updated?
Matt,
It does not exactly reply to your question. Please consider NOT to update / edit a textbox in a grid, use instead a textbox outside the grid. To be sure your textbox is updated, when txtbox ControlSourse is a cursor apply the 'safeselect' procedure as developped by Andy Kramek. This works 100% always. Regards, Koen
2017-09-25 17:29 GMT+02:00 Matt Slay mattslay@jordanmachine.com:
No buffering is involved.
In fact, if you tab over two columns, you finally get the expected calculated value from the logic in the AfterRowColChange() method. I see why... The first column move the method does not the new values, but once that move is complete, then the value in the cursor is updated, so that when you move a second time, it then has the new value so the calculation works correctly. However, I cannot let my user experience this odd latency.
BTW - The calculate in the AfterRowColChange updates a property on a data object and that property is displayed in another read-only textbox outside of the grid. So, when they user enters a new value in the grid column, and tabs over, they expect to see the other textbox update to show the new calculated value from their data entry in the grid.
Here is basically the code that gets fired in AfterRowColChange():
Procedure AfterRowColChange()
Thisform.oBusinessObject.UpdatePropertiesFromGridCursor() Thisform.Refresh()EndProc
*Matt Slay*
On 09/25/17 10:07 AM, Richard Kaye wrote:
Some other thoughts. Is this cursor inside a transaction? If so, what kind of buffering do you have set? If you are row buffered and moving from column to column in your grid, no implicit replace or update operation will happen unless you move the record pointer, right?
--
rk
-----Original Message----- From: ProfoxTech [mailto:profoxtech-bounces@leafe.com] On Behalf Of Matt Slay Sent: Monday, September 25, 2017 10:56 AM To: profoxtech@leafe.com Subject: Textbox in grid column.... When is cursor updated?
Textbox in grid column question.... When is the value entered in a textbox in a grid column applied to the underlying bound cursor relative to the firing of the grid.AfterRowColChange() when user hits tab to move to the next column?
Here is the situation I am struggling to understand: When entering a new value in a column and then hitting tab to go to the next column, it appears that the value from the textbox which you are exiting is not applied to the cursor yet at the time AfterRowColChange() fires. I have some calculation logic on AfterRowColChange() and the old value is what I am seeing.
As a hack, I have gone this route, but I hate it: In order to get the value from the textbox in the cursor soon enough to be seen by the AfterRowColChange() method code, I have put explicit code in the textbox.Valid() to say “Replace {field} with This.Value in {lcCursor}” and then the cursor is updated so that when AfterRowColChange() is called, it will see the new value in the row for that field.
Am I making any sense with this explanation? What am I missing?
--- StripMime Report -- processed MIME parts --- multipart/alternative text/plain (text body -- kept) text/html
[excessive quoting removed by server]
_______________________________________________ Post Messages to: ProFox@leafe.com Subscription Maintenance: http://mail.leafe.com/mailman/listinfo/profox OT-free version of this list: http://mail.leafe.com/mailman/listinfo/profoxtech Searchable Archive: http://leafe.com/archives/search/profox This message: http://leafe.com/archives/byMID/profox/CACUu1SsHY+=yR+_dnvi2MJBvUv151nYCcotO... ** All postings, unless explicitly stated otherwise, are the opinions of the author, and do not constitute legal or medical advice. This statement is added to the messages for those lawyers who are too stupid to see the obvious.
On 2017-09-25 10:55, Matt Slay wrote:
Textbox in grid column question.... When is the value entered in a textbox in a grid column applied to the underlying bound cursor relative to the firing of the grid.AfterRowColChange() when user hits tab to move to the next column?
Here is the situation I am struggling to understand: When entering a new value in a column and then hitting tab to go to the next column, it appears that the value from the textbox which you are exiting is not applied to the cursor yet at the time AfterRowColChange() fires. I have some calculation logic on AfterRowColChange() and the old value is what I am seeing.
As a hack, I have gone this route, but I hate it: In order to get the value from the textbox in the cursor soon enough to be seen by the AfterRowColChange() method code, I have put explicit code in the textbox.Valid() to say “Replace {field} with This.Value in {lcCursor}” and then the cursor is updated so that when AfterRowColChange() is called, it will see the new value in the row for that field.
Am I making any sense with this explanation? What am I missing?
Hi Matt,
That workaround is exactly what I did almost 20 years ago when trying to do the same thing in a VFP6 app. Then, thanks to tips here (or the predecessor, FoxShare by Darcy White?), I changed the design to not do editing in grids directly but pop up an edit form instead, using objects in said-pop-up-form and then doing a GATHER in the underlying cursor if the user pressed Save in the edit form.
Your scenario above reminds me of similar workarounds due to the Toolbar object not getting focus as expected. Saw that in FoxPro Advisor back then!
--Mike