473,386 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Persisting field form values

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
Mar 26 '08 #1
4 1159
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.

--

BlackWasp
www.blackwasp.co.uk
"John" <in**@nospam.infovis.co.ukwrote in message
news:uX**************@TK2MSFTNGP05.phx.gbl...
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

Mar 26 '08 #2
On Mar 26, 3:22*pm, "John" <i...@nospam.infovis.co.ukwrote:
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
Binding the form elements to a simple database would be the easiest
way.
Mar 26 '08 #3
On Mar 27, 12:22 am, "John" <i...@nospam.infovis.co.ukwrote:
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
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
Mar 26 '08 #4
"John" <in**@nospam.infovis.co.ukschrieb:
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>

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

Mar 26 '08 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: James Baker | last post by:
I have a form that has a dropdown list that will cause a post to the same page when it's changed. The problem I'm running into is that all of the controls reset to their default values (obviously...
2
by: Citoyen du Monde | last post by:
Trying to get some ideas on a simple javascript project (to teach myself the language). I want to develop a client-side vocabulary practice application that would allow users to enter their own...
7
by: Derrick | last post by:
Can anyone tell me how to persist and retrieve the font characteristics that a user chooses to have displayed in a personalized label field on the front of their application? I wanted to be able...
3
by: Tom | last post by:
Hi, I am looking for an article or tutorial on persisting winform user input for the life of the app. How to design it? For instance, do I create a container class specific to each form? This...
4
by: Dave Veeneman | last post by:
When does serializing objects make more sense than persisting them to a database? I'm new to object serialization, and I'm trying to get a feel for when to use it. Here is an example: I'm...
2
by: Hai Nguyen | last post by:
I have several different tables with textboxes I want user fill out some information into those boxes and after hit save, I want to store all those values from those textboxes into database I...
1
by: lim | last post by:
What is the possible error that occurs when the Page_load event is not triggered during execution. In my page there's some basic server control. Is there any loops holes?
2
by: xenophon | last post by:
I added a Hidden Form Field to a form in the code behind. The value is being set in JavaScript client-side, but it is not persisting to the server in the PostBack. I know the value is being set...
1
by: neobonzi | last post by:
Hello! I'm dynamically creating a GridView bound to a datatable using custom template columns using the following method: protected void ShowGrid(DataTable dt) { ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.