Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid content disappears--not the usual problem
Message
From
13/04/2009 08:19:44
 
 
To
10/04/2009 17:05:39
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Environment versions
Visual FoxPro:
VFP 9 SP1
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01394193
Message ID:
01394537
Views:
64
>>>I've got a grid misbehaving (and reminding me how much I hate using grids <g>). The grid's RecordSource is a cursor (csrAlarms) that I create in the Form.Load. There's a method (GetAlarms) that populates the cursor and another (SetupGrid) that sets up the grid columns as I want them. Both are called from Init. When the grid first displays, all is as I expect.
>>>
>>>GetAlarms uses a "safe select" sort of technique. It's a little more complicated because the data is actually sitting in a collection, but the code fills a second cursor (csrTempAlarms) from the collection and then does this:
>>>
>>>
>>>ZAP IN csrAlarms
>>>INSERT INTO csrAlarms ;
>>>	SELECT * FROM csrTempAlarms
>>>
>>>GO TOP IN csrAlarms
>>>
>>>
>>>
>>>Periodically, a timer fires and as part of its processing, it calls a method called RefreshAlarms, which contains this code:
>>>
>>>
>>>This.LockScreen = .T.
>>>This.GetAlarms()
>>>This.grdAlarms.Refresh()
>>>This.LockScreen = .F.
>>>
>>>
>>>The problem is that if the user clicks on the grid, including its header or scrollbars, sometimes all the data in the grid disappears. If I prevent RefreshAlarms from being called, the grid behaves, so this is somehow tied into the refresh process.
>>>
>>>I've tried with and without setting LockScreen. I've also done some event tracking and didn't turn anything suspicious up.
>>>
>>>I know what the work-around is--put a transparent shape over the grid so the user can't click on it. I'll do that if I have to, but I don't want to because eventually, I have to make the grid sortable by clicking on the column headers, and that'll be a real PITA with the shape. (Yes, I know how to do it; I'd just rather not.)
>>>
>>>So, any ideas about what could be making this grid behave this way?
>>>
>>>Tamar
>>
>>There are two reasons for disappearing contents:
>>1. Grid had focus at the point of Zap/Insert. You may move focus away in your code, right before Zap.
>>2. Form is corrupted.
>>It might happen that your timer plays havoc in regard to #1. I always use the same way to populate grids and it never required timer usage. Simple refresh or setfocus after Insert is quite enough.
>
>The timer isn't in order to get the grid refreshed per se. The timer is checking for data coming in from an outside source, handling that data, and then calling the code to refresh all open forms with the new data.
>
>Based on our response and Naomi's, I need to clarify that the problem occurs when the user clicks on the grid. I'll double-check, but I'm pretty sure that as long as that doesn't happen, all the refreshes work just fine.
>
>Tamar

When user clicks on grid, focus is moved there. In this case, you could move focus away in code before zap/insert. You may set it to any control on your form, and then return it back to grid after insert.
Edward Pikman
Independent Consultant
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform