Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
How to fill a grid control using a dbf created by a Sql
Message
From
17/08/2001 05:36:07
 
 
To
17/08/2001 03:05:00
Devrishi Bhogra
Escorts Claas Limited
Faridabad, India
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00545167
Message ID:
00545182
Views:
12
>Hi there!!
>
>i am trying to fill my grid control using a dbf created on the fly using through some sql statement.
>
>select * from itemmast into dbf temp
>
>*-- name of my grid control is grid1
>
>grid1.recordsourcetype = alias
>grid1.recordsource = temp
>
>
>but it doesn't display anything....booohhhh!!!!
>
>So please Help
>
>Regards
>
>Sunny




Some more code to be done!
select * from itemmast into dbf temp

select temp   && Optional if the current alias is already Temp
With ThisForm.Grid1
   .ColumnCount = -1    && Remove all column, header, textbox objects in grid
   .RecordSourceType = 0
   .RecordSource = []
   .RecordSourceType = 1
   .RecordSource = [Temp]
   .Init    && You can add some code on INIT to change custom textbox, header class on it.
EndWith



Why reset ColumnCount by -1, if you direct change the grid recordsource.
it will use OLD alias column width.. the table show will be ugly.

Moreover, once you change the recordsource, all objects are gone and being reset..
If you have code on header or textbox, it will NO LONGER work more.

Thus, better to do a huge reset on grid.
Create own textbox on VCX, or header class in Code (Header class only can created by coding.)

Furthermore, I donno it is a bug or not,
You get great chance on successful assign grid recordsource when Current Work Area is same alias.
I was wonder VFP ignore my assign coding on grid recordsource if objects are created by AddObject(), CreateObject()
That unbelievable fact was found about 2 years ago.


Then, at Grid.init, add some code like:
* Grid.Init
With This
FOR ix = 1 to .ColumnCount
   .Columns[ix].RemoveObject([Text1])
   .Columns[ix].AddObject([Text1], [txt])
   .Columns[ix].Text1.Font = [Arial]
   .Columns[ix].Text1.FontSize = 11
   .Columns[ix].Text1.Visible = .T.     && All objects create by "AddObject" default visible is .F.
ENDFOR
EndWith
Then, whatever you change grid recordsource, call INIT will reset the column and textbox as you standard!

For more detail coding, you can try to download my Browse current directory Table by Grid (VFP 5.0 sample)

http://members.tripod.com/~justok/bwtable.zip

(This is one of the file section download.)

My example will use cursor instead of real table, because I can do many search on cursor.
Overwrite and re-use cursor in VFP 5.0 will be more flexible then 6.0! :)

try to recompile it and place the bwtable.exe to your data file directory.
then make a search condition and RightClick on [search] button.

You will see the SELECT-SQL cursor result. :)
The weak wait for chance, The strong bid for chance,
The clever notch up chance, but The merciful give you chance.
Previous
Reply
Map
View

Click here to load this message in the networking platform