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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problems with AfterRowColChange event

Status
Not open for further replies.

ralphcarter

Programmer
Aug 8, 2006
28
US
I have a grid set up to that the header of certain columns can change depending on the value in another column in that row. I have put the code to effect this change in the LostFocus event of the combobox control in that column. I then fire the LostFocus event in the AfterRowColChange event of the grid. Everything works great when I scroll down. However when I scroll up in the grid the changes seem to lag one record behind. Anyone have any ideas here? I hope I have been descriptive enough. BTW I am using VFP 7.0

Thanks,
Ralph
 
Ralph,
Can you post the code you have in your AfterRowColumnChange event? May be something in there...


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Here is all of the relevant code.


***********************************************************
*BeforeRowColChange
thisformset.gridrow = this.ActiveRow


***********************************************************
*AfterRowColChange
*
IF this.ActiveRow <> thisformset.gridrow THEN
this.column7.cbolbuom1.LostFocus
ENDIF
thisformset.gridrow = this.ActiveRow

***********************************************************
*column7.cbolbuom1.LostFocus
*
IF THIS.Value = " 0" THEN
this.Parent.Parent.column15.header1.Caption = "M$/Lb: Glvlm"
this.Parent.Parent.column16.header1.Caption = "M$/Lb: White"
this.Parent.Parent.column17.header1.Caption = "M$/Lb: Color"
this.Parent.Parent.column18.header1.Caption = "M$/Lb: Kynar"
this.Parent.Parent.column9.Width = 0
this.Parent.Parent.column9.Visible = .F.
this.Parent.Parent.column8.Width = 75
this.Parent.Parent.column8.Visible = .T.
ELSE
this.Parent.Parent.column15.header1.Caption = "M$/UOM: Glvlm"
this.Parent.Parent.column16.header1.Caption = "M$/UOM: White"
this.Parent.Parent.column17.header1.Caption = "M$/UOM: Color"
this.Parent.Parent.column18.header1.Caption = "M$/UOM: Kynar"
this.Parent.Parent.column8.Width = 0
this.Parent.Parent.column8.Visible = .F.
this.Parent.Parent.column9.Width = 75
this.Parent.Parent.column9.Visible = .T.
ENDIF
 
Hmmm... it does look ok. Just out of curiosity, in your AfterRowColChange, try putting in after your ENDIF:

This.Refresh()

And see if the fixes it.


Best Regards,
Scott

"Everything should be made as simple as possible, and no simpler."[hammer]
 
Tried the this.refresh and it didn't help. It almost seems as if there is some sort of sync problem when scrolling backwards.

Any thoughts anyone?
 
Hi Ralph,

I suspect the LostFocus() may be firng of its own accord. It is a good practice not to put code in events. Try creating a CheckColumns method for your grid. Put the code from cbolbuom1.LostFocus in CheckColumns and call it from both the AfterRowColumnChange and the cbolbuom1.LostFocus. See if that helps.

pamela
 
Pamela,

Thanks for the idea but it didn't work any differently than with the code in the lost focus.

Everyone,

Is this different than something that would normally be done with a foxpro grid? I am not very proficient in foxpro and unfortunately I have not seen very many good examples of what to do here.

Has anyone else tried to make changes based on the row in a grid and noticed that when scrolling backward that the cursor appears to be behind one line even though when scrolling forward it works?

Is this something that happens in Foxpro 7 but was fixed in 8 or 9?

Inquiring minds want to know


Ralph
 
Hi Ralph,

I have never heard of the phenomena you describe and I have been using Fox since 2.0. But then I can't say that I have heard of anyone doing exactly what you describe.

When you say appears to be behind one line, are you saying that the header captions aren't consistent with what is being displayed in combo column? Or are you experiencing some other visual effect?

pamela
 
The header captions always reflect the row just vacated when scrolling backward instead of the current row. When scrolling forward they reflect the current row.

Thanks for the help

Ralph
 
Ralph

Instead of this.refresh()
try
thisform.refresh()
You might also try
this.parent.parent.refresh()
if thats the grid.

Andrew
 
Ralph,

Try putting a breakpoint in the ChangeColumns method and check the value of This.ActiveRow and Thisformset.GridRow and Column7.cbolbuom1

It seems like some kind of timing issue.

pamela
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top