Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2008

Tip: Looking for answers? Try searching our database.

Persisting field form values

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John - 26 Mar 2008 23:22 GMT
Hi

I have a form with a couple of text boxes and a list box. The user is able
to type text in text boxes and add elements to the list box. My question is;
how can I persist the values in these fields so they remain when the form is
closed and opened again by the user, either in the current session of the
app or after closing the app and rerunning it?

Thanks

Regards
BlackWasp - 26 Mar 2008 23:46 GMT
To persist between sessions you need to store the data somewhere other than
the application.  The location you choose will depend upon the application,
the environment and whether you need the stored information to follow the
user around the network.

Usual suspects for storage spaces are:

* An XML configuration file
* The registry
* A database

but of course there are many other possibilities too.

Signature

BlackWasp
www.blackwasp.co.uk

> Hi
>
[quoted text clipped - 7 lines]
>
> Regards
Inictus - 26 Mar 2008 23:51 GMT
> Hi
>
[quoted text clipped - 7 lines]
>
> Regards

Binding the form elements to a simple database would be the easiest
way.
Herfried K. Wagner [MVP] - 26 Mar 2008 23:56 GMT
"John" <info@nospam.infovis.co.uk> schrieb:
> I have a form with a couple of text boxes and a list box. The user is able
> to type text in text boxes and add elements to the list box. My question
> is; how can I persist the values in these fields so they remain when the
> form is closed and opened again by the user, either in the current session
> of the app or after closing the app and rerunning it?

Application Settings Overview
<URL:http://msdn2.microsoft.com/en-us/library/k4s6c3a0.aspx>

Signature

M S   Herfried K. Wagner
M V P  <URL:http://dotnet.mvps.org/>
V B   <URL:http://dotnet.mvps.org/dotnet/faqs/>

kimiraikkonen - 26 Mar 2008 23:57 GMT
> Hi
>
[quoted text clipped - 7 lines]
>
> Regards

You can store listbox content in a text file, and there are other ways
such as XML serialization, db...

See this that contains reading and writing listbox content into a
textfile:

To store listbox content in a text file:

Dim ItemArray(Me.ListBox1.Items.Count - 1) As Object
Me.ListBox1.Items.CopyTo(ItemArray, 0)
Dim Data As String = Join(ItemArray, Environment.NewLine)
My.Computer.FileSystem.WriteAllText("c:\data.txt", Data, False)

The parameters of WriteAllText method are up to you (append, data,
path...)

But remember that, your text file will get bigger and unresponsive due
to large amount of text lines over the time, then you may want to
create a new text file.

To get the content of textfile into your listbox:

Dim reader As String
reader = My.Computer.FileSystem.ReadAllText_
("c:\data.txt")
Dim strs() As String
strs = Split(reader, Environment.NewLine)

For Each s As String In strs
ListBox1.Items.Add(s)
Next

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.