|
-
June 20th, 2001, 02:21 PM
#1
Save Contents in MSFlexgrid
What's the code for saving the contents of an MSFlexgrid control????
--Ant
--------------------------------------------------
check out my newest freeware
E-mail me at: [email protected]
for the address
-
June 20th, 2001, 02:31 PM
#2
Re: Save Contents in MSFlexgrid
If someone can come up with a more sensible solution than this, I'd really really love to read it...
Best way I know of to save the data in a Flexgrid is just to send it all to a text file. Write a Sub in a standard module that will export the data and write one that can load the data.
To save it all, it would probably be best to use a nested for..next loop.
For X = 1 to Flexgrid.Rows
For Y = 1 to Flexgrid.Cols
Buffer = Buffer & Flexgrid.Textmatrix(X,Y) & vbTab
Next Y
Buffer = Buffer & vbCrLf
Next X
...or something of that nature.
-
June 20th, 2001, 03:13 PM
#3
Re: Save Contents in MSFlexgrid
ok, i got the load and save subs, but where would i put the for loop?
--Ant
--------------------------------------------------
check out my newest freeware
E-mail me at: [email protected]
for the address
-
June 20th, 2001, 03:18 PM
#4
Re: Save Contents in MSFlexgrid
Inside your save sub, create a string (i called it Buffer in my example) and then use that loop structure to create a big huge string that has all the rows on separate lines (thanks to the "Buffer = Buffer & vbCrLf" line) and it will have all the columbs tabbed (vbTab).
Then you'll need some code to put the buffer in a file; I would use the CommonDialog control and use the .ShowSave method to allow the user to choose where to save the file.
CommonDialog1.ShowSave
Open CommonDialog1.Filename for Output As #1
Print #1, Buffer
Close #1
Does that help some? 
-
June 20th, 2001, 05:25 PM
#5
Re: Save Contents in MSFlexgrid
it helped. now i gotta put it all together.............
--Ant
--------------------------------------------------
check out my newest freeware
E-mail me at: [email protected]
for the address
-
June 21st, 2001, 07:41 AM
#6
Re: Save Contents in MSFlexgrid
Why do you want to save MSFlexGrid?. If you want tosave the content on the disk in order to download it later, I think it is a good solution to create a recordset from the flexgrid and save it as xml file
Rst1.Save "c:\Temp\Recordset.xml", adPersistXML
Later you can download from the file to the recordset and restore the flexgrid.
Another advantage of this method is that it will save not only data but also a structure. For example you can save a content of MSHFlexGrid and retrieve the structure later.
Iouri Boutchkine
[email protected]
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|