Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

keep TEdit informaion

Status
Not open for further replies.

hayate

Programmer
May 17, 2003
7
JP
Hi,
This is what I want to do...

I use 2 forms. Form1 has a Listbox, an Edit, and two Buttons.I input someone's name to the Edit.Then when I push the Button, the name will be added to the ListboxItems.
When I push the other Button, Form2'll be shown which has 3 Edits and one Button. Edit1 has the name added to the listbox.Other user information will be input to Edit2&3.

These are not challenging but the problem is next step.

I want to keep the information added in Form2 while I run the application. So, for instance, if I input the name A in Form1, then add some information in Form2 and close Form2.Next time I open Form2, the information I input in Form2 will be kept and shown again.

How can I keep the information? I tried WriteComponent and ReadComponent but the performance didn't meet my expectation.
I want to use AssignFile and save information to files but there's several Edits and I don't really know how to do.

Any help will be greatly appreciated.
 
You could do this several ways. the most detailed would be to create a table but if you are only storing a couple of values then it wouldnt really be necessary.

The second thing you could do is to create an inifile but this might not be a good approach from what you have described.

Finally, (assuming my mental picture even remotely matches what you have designed this is the one I would recommend) you could save the listbox values/text as a file using the Listboxes SaveToFile and LoadFromFile commands.

See the delphi help file for more info on all these three approaches as there isnt enough room here to go into great detail on these three subjects.

Arte Et Labore [rockband]
 
Just to expand on EricDraven's ideas, if this is just a simple scenario then go with the ListBox's LoadFromFile and SaveToFile methods. They are extremely easy to use:

To save the listbox items:
Code:
  ListBox1.Items.SaveToFile('C:\temp\ListValues.txt');

To load the listbox with items in file
Code:
  ListBox1.Items.LoadFromFile('c:\temp\ListValues.txt');

Hope this helps!

Clive [infinity]
Ex nihilo, nihil fit (Out of nothing, nothing comes)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top