Click to See Complete Forum and Search --> : Persisting MSFlexGrid and other Controls - HOW ???
cmjoshi
Mar 28th, 2002, 01:31 PM
I am building a prototype using VB6. This prototype consists of 2
screens. First screen has 11(eleven) MSFlexGrids and Second screen has
mixture of all controls( textbox, combobox, listbox and msflexgrid ). I
have requirement to store different scenarios of my application.
Suppose, i open my application and lets say get data in both the
screens. Then, i need to click on a "Save" button which should save all
the data present in both the screen on to a file on hard disk with a
file name called as "Scenario1". Then, i change some of the information
and click on "Save" button. Now i have to store the data as "Scenario2".
I have another button called as "Retrive Scenario". When i click on this
button and ask for "Scenario1" data, i need to get back all the
information from the file "Scenario1" automatically in both the screens.
If i request for "scenario2", then data should be populated from
"Scenario2" file.
I got stuck into it and don't know how to proceed furthur. PLEASE HELP!
Edneeis
Mar 28th, 2002, 04:18 PM
Well post what code you have and we'll go from there.
swb76
Apr 13th, 2002, 10:06 PM
you didn't mention where did you get stuck?...give us something to work with.. tell us how did you propose to do it..
My suggestion is very simple..may be its implementation isn't exactly simple...
create a user-defines class Named 'Scenario' -
this data structure would have all the variables necessary and the properties to access it. It would also have a save method which you would call everytime the user clicks save...
you would have a collection of scenarios that would be used when the user clicks retrieve..
so any screen where the user clicks "Save"
1) create a new class scenario...
2) grab the data from the form..
3) save the scenario in your collection and also in the DB
if user clicks "retrive scenario"
just display all the sceanario names from your collection in a listbox..and expect user to click on one..if u want to display all the scenarios created by other exectutions of this program then load those scenarios(as a collection) at the beginning of the program.. and display both the collections..
i hope i have answered your question..
cmjoshi
Apr 22nd, 2002, 08:45 AM
Hi there,
Thanks a lot for your information. Well, most of the part where i got stuck is answered by you. I am supposed to store the data into files on hard disk with scenario names as file name. Do i need to loop around all the cells in all the grids and then write it to a file. Why can't i store whole grid itself into a file ? Java does that it seems. It store the objects into files using some object streaming functionality. I wonder why VB can't do it ! If you know anything about storing grids/textbox/listbox etc... into files, please let me know.
Thanks a lot for your help. Appreciate it greatly!
Thanks,
Josh
swb76
Apr 22nd, 2002, 12:40 PM
you can store the grid using
grid.savegrid..
u can store the contents of the text box, etc. in a database..
while loading ; load the grid using LoadGrid..
hope this helps
rudgej
Apr 22nd, 2002, 01:06 PM
LoadGrid and SaveGrid are not part of the standard flexgrid that comes with VB6. Are these not perhaps features or the FlexGrid Pro version of the control?
powdir
May 1st, 2002, 01:34 PM
probably in agreement with swb76
create a user class, called say clsScenario, with a method such as SaveScreen. This method will take a FlexGrid as an (incoming) argument. In your form declare an instance of this class and pass in your forms FlexGrid through the exposed SaveScreen method.
Inside the clsScenario class, the SaveScreen method could read the contents of the FlexGrid and and save to disk - You could try using the ProperyBag to persist the whole FlexGrid object using class_writeProperties
cmjoshi
May 2nd, 2002, 08:27 AM
Hi,
I tried the way you explained about the clsScenario. But problem is i don't want to loop around instead store the grid itself. I have read about the PropertyBag object but it says it could store the objects, yes. But to my knowledge, it cannot store the controls itself. If you know more about storing controls using PropertyBag, please let me know.
Thanks for your explaination. Appreciate it a lot.
Josh
powdir
May 2nd, 2002, 09:37 AM
yep see your point,looping throught he cells of a flexgrid would be a little untidy.
Is using a flexgrid a must displaying data from a recordset? If yes you could use a DataGrid instead and use it's save method to persist the data.
I have in the past used a class as a method of validating/saving the contents of a form. You pass in the form and loop through the controls asiging their individual contents to matching properties of the class, the PropertyBag can then be used to persist the forms values. And retreive them using the reverse!
you need to declare the class_writeProperties/readProperties methods inside your class and you can only persist public classes - not private (as in a wee application's class). I can post code if that would help.
An object can be persisted in this way and since the flexgrid on your form is an object I assume there is a way of saving , wholesale, it's contents. HMMMM
What is the source of your data? is it from a DataBase?
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.