Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Grid column order
Message
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00643125
Message ID:
00643262
Views:
7
The following from the FAQ you sent me appears to be what I need.
However, due to lack of experience I'm uncertain how to utilize this code.
Where exactly is it placed? What goes in the "............" part of the code, where he says "* do refreshing of the record source" ?

All I'm trying to do is display the table with the columns ordered as I desire. Do you have an sample code or experience with this?

Thanks,
Doug

"1. Grid reconstructs itself always when the RecordSource alias is closed. If this is a view, reconstruction usually do not happens when you requery view, however, there are some reports that this could happen, so test your application carefully to see if view requery causes the grid reconstruction. If it is SQL statement, it happens when you’re issuing another SQL statement or just close the alias used to store results of the query for grid. It also happens when you use SQL Pass-Through to query data into the alias that used as a record source of grid.

To avoid reconstruction when refreshing grid's record source, you’ll require assigning an empty string (not a one space - " ", but empty string - "") to the Record source before any of the grid's record source refresh actions described above. If you already do that, just check your code to verify that you’re doing it in the correct order and nothing else spoils the correct order of the refreshing process. After refresh assign the record source to the grid again. Reconstruction in such cases does not happen, however, another problem arises - all the grid's columns re-bound to the control source automatically by the physical fields order. Following is a sample of how to fix that by using a little code.

* remember control sources in the column's comment field
with {grid}
local nColumnIndex
for m.nColumnIndex = 1 to .ColumnCount
.Columns(m.nColumnIndex).Comment = .Columns(m.nColumnIndex).ControlSource
endfor
* prepare grid for refreshing of the Record Source
.RecordSource = ""
endwith
* do refreshing of the record source
...........
with {grid}
* restore record source
.RecordSource = "{RecordSourceName}"
* restore control sources
for m.nColumnIndex = 1 to .ColumnCount
.Columns(m.nColumnIndex).ControlSource = .Columns(m.nColumnIndex).Comment
endfor
endwith

In above code {grid} is a reference to the grid object, {RecordSourceName} is a name of the alias used as a record source or SQL statement."
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform