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

Grid doesn't always refresh

Status
Not open for further replies.

friend01

Programmer
Jun 4, 2009
94
CA
Hi,

I have a problem with my grid where it doesn't seem to 'refresh' properly all the time. I'd say about 80% of the time it works fine but 20% it doesn't. I know it's a 'refresh problem' because if I open & close the app it appears correctly. I have to following specs:

data environment - 1 dbf with a filter to 1 field

in my form specs are as follows:

init method:
This.Show()
READ EVENTS


load method:
SELECT the dbf
SET DELETED ON
SET ORDER TO
GO TOP
THISFORM.REFRESH()



any hel on this ongoing enigmaitc problem. why is it that the refresh doesn't work? is there somehitng I should pu in the refresh method? IS there a timer I should put with something in it to 'force refresh'?

any help please.

thanks,
F1

 
Hi,

OK, so I have this now after tests. In my Timer code:

thisform.grid1.Enabled=.t. (I did this because the grid enabled is set to .f. and I cannot setfocus unless it's enabled)
THISFORM.grid1.SetFocus()
SCAN FOR DATE()>dateupd
REPLACE needupd WITH .T.
IF tticket.sentremail =.F.
DO updemail
REPLACE tticket.sentremail WITH .T.
ENDIF
ENDSCAN

It does't seem to go to EOF now (which is good it goes to the last recno (not eof) which is good).

Now, I haev a slight issue since I have to thisform.grid1.Enabled=.t.. The problem is that the font of the last record of the field of the first colum of grid because realy small).

Any thoughts. It didn't do that obviosuly when it was disabled. Any thoughts.

BTW, how's the code look so far in my Timer? Any thoughts on if you think it's OK now?

Let me know.

Thanks,
F1
 
You don't need to SET REFRESH TO 2 in a time, this is a setting you set once and it works from there. It's not a replacement for a grid refresh, it refreshes the data within the alias.

Second: While a SCAN ENDSCAN loop may be better in putting you to the last record instead of EOF, you normally want to keep the grids current record where it is, so I'd rather USE the table AGAIN with another ALIAS name and then scan through that.

Bye, Olaf.
 
Hi,

OK, so I put the "SET REFRESH TO 2" in my .prg which launches/calls my form. Now, in my timer, I have:

thisform.grid1.Enabled=.t.
THISFORM.grid1.SetFocus()
SCAN FOR DATE()>dateupd
REPLACE needupd WITH .T.
IF tticket.sentremail =.F.
DO updemail
REPLACE tticket.sentremail WITH .T.
ENDIF
ENDSCAN

this seems right so far, yes?

Now, I'm just a little confused in where do I put the following:

USE tticket AGAIN ALIAS tticket2 ORDER tpriority

Do I issue this command instead?
USE tticket IN 0 AGAIN ALIAS tticket2 ORDER tpriority

the other problem is that everywhere in my grid and as per DE, it's pointing to tticket not tticket2 if I issue the USE AGAIN command. Will I have to change everything in my grid and my code to point to tticket now? Is there any suggestions??

At least I'm getting somewhere though, yes? :)



 
I suspect in your case, where you want newly added records displayed in the grid you do NOT want to implement Olaf's suggestion. His suggestion is fine when you want to always display the same record, but that's not what you're doing.

Is your font issue a vestige of the record being selected?
 
Danfreeman, correct in your suspicion. You are correct as I do not always want to display the same record as you said. You are correct.

Yes, font issue and seems to be a vestige of the record being selected. Also, at the same time, it "hilites" the field as if it were 'selected'. Any work around because it looks as if the record is hilited in my grid. Any help on this?

does my timer code seem OK? Am I missing anything you think?

please let me know.

thanks,
jj
 
I'd start by setting the grid's AllowCellSelection to .f.

There are MANY Font properties on the grid, each column, and the contained controls. You'll have to see if you've changed any of those.
 
Okay, forget my suggestion, if you dont wnat to display the same record(s).

I was thinking along this lines:

You have a grid displaying tticket, you want to display all records of it, but also process them in a timer, without disturbing what record position tticket is in the grid, then you'd open the ttickets table AGAIN and keep adressing tticket in the grid, you only will want to SELECT tticket2 in the timer, before scanning tticket2. It's only another alias for the same table, so the changes you make in tticket2 will reflect in then tticket alias. And still you won't move the record pointer in tticket.

I'm still quite sure you want this, but then I'm not you.

I'm at a point where I'd be willling to take a look at your form and if you tell me what exactly you want achieve make it work. This thread seems quite fruitless to me, as you are only making baby steps and not understand the suggestions we make.

this is no place to repeat everything the help says on certain things and commands. You have to do some reading in the help to comprehend, sorry.

Bye, Olaf.
 
This is a very good example of How NOT to ask for help... 46 posts later, I still do not have a clue as to what you are trying to do...The information you provide is in dribs and drabs insuring no one can really help you... sorry had to be said...
 
Friend,

Perhaps the best thing you can do now is to start from scratch. Create a new form, add your grid, and then add one feature at a time. Focus on getting that feature working. If it doesn't, post a specific question. If it does, keep going until it stops working.

Mike

__________________________________
Mike Lewis (Edinburgh, Scotland)

Visual FoxPro tips, advice, training, consultancy
Custom software for your business
 
Hi All,

I appreciate all your patience & help. I think I got it right and in essence what Olaf is saying is what I'm trying to do. I have a grid displaying tticket, I want to display all records of it, but also process them in a timer, without disturbing what record position tticket is in the grid. So, this is what I did according to what I'm pretty sure is what needs to be done. Please let me know if this makes sense now.

In My Timer:

thisform.grid1.Enabled=.t.
THISFORM.grid1.SetFocus()
THISFORM.grid1.Column1.FontSize=30 &&fixes bug on fonstsize
SELECT tticket2
SCAN FOR DATE()>tticket2.dateupd
REPLACE tticket2.needupd WITH .T.
IF tticket2.sentremail =.F.
DO updemail
REPLACE tticket2.sentremail WITH .T.
ENDIF
ENDSCAN


in my .prg which calls/launches the form:
some code stuff..
USE tticket AGAIN IN 0 ALIAS tticket2


I believe I finally got (if I'm understanding you all right). What do you think? Any comments?

Again, thanks for your patience & understanding & I apprecaite all the time you've been taking.

What do you all think? :)


Thanks,
F1


 
yes, now you have two aliases, scanning in tticket2 does not change positioning in tticket, which I assume is still the recordsource of the grid.

Now does that work out or does the grid still not refresh, if you change data in tticket from a secondary app?

Bye, Olaf.
 
Hi,

Yes, everything seems to be working & refreshing (so far so good). Also, yes, tticket is still the recordsource of the grid & all seems to be working nicely.

Thanks to all for their help & patience.


Thanks again,
F1
 
okay,

now for the sake of stability I suggest you still add this, even though it works for now:

If the timer event does take longer than the timer interval, you might get in a situation where the timer stops working, therfore at the begin of the timer event make THIS.Enabled = .F. and at the end of the timer event set THIS.Enabled = .T.

Then this cannot happen, even if this is already the standard behavior of a timer event to be non reentrant while it's still runninng.

Bye, Olaf.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top