Before you change anything that would affect the underlying cursor, just
issue this command:
thisform.grid1.recordsource = ''
do your changes
thisform.grid1.recordsource = 'theunderlying cursor'
Rafael Copquin
El 18/03/2013 03:15 p.m., John J. Mihaljevic escribió:
Hi all,
I have a form that accepts an order number. When the user enters the order
number, it first validates that number to make sure it exists, and then
creates a grid which displays the order detail. If the user changes that
field to an invalid order number, I have that grid disappear.
The problem is, if the user then enters another valid order number, the grid
still displays, but all the settings are screwed up (column headings, column
widths, etc.). I can programmatically fix those things with code such as
"thisform.grid1.column1.caption=" etc., but I'm losing things such as click
events for the column headers, click events for the rows of the grid, etc.
Is it possible to either:
1) Repopulate this grid without losing all of its formatting, or
2) Recreate the events programmatically
Here's a chunk of my code from the form-level method I created to populate
the grid (populategrid):
fieldcount=fcount()
if !used("orderdisplay")
use orderdisplay in 0 excl
endi
sele orderdisplay
use orderdisplay excl
old_safe=set("safe")
set safe off
zap
set safe &old_safe
for i=1 to fieldcount
sele orderdata
fieldname=field(i)
datainfield=&fieldname
*
* Convert all non-character data types to character
* so they can be viewed in the grid.
*
ismemo=.f.
do case
case type(fieldname)="C"
datatosave=datainfield
case type(fieldname)="T"
datatosave=dtoc(datainfield)
case type(fieldname)="M"
ismemo=.t.
datatosave=datainfield
otherwise
datatosave=str(datainfield)
endc
*
* Add a record to orderdisplay for each field in the
orderdata table..
*
sele orderdisplay
appe blan
repl field with fieldname, data with datatosave
if ismemo
repl memo with datatosave
endi
endfor
go top
thisform.grdIPSR.RecordSource=""
thisform.grdIPSR.RecordSource="ipsrdisplay"
thisform.grdIPSR.refresh
Thanks very much!
John
[excessive quoting removed by server]
_______________________________________________
Post Messages to: [email protected]
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/[email protected]
** 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.