473,404 Members | 2,114 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,404 software developers and data experts.

TextBox Query

Sorry, this must be very elementary:

When writing line 1 to a textBox,
pressing return
writing line 2 to same tetBox.

Saving that to disc.
using (StreamWriter sw = new StreamWriter ("memo.txt"))
{
sw.WriteLine(textBox1.Text);
}

Reading that from disk.
using (StreamReader sr = new StreamReader ("memo.txt"))
{
textBox1.Text=sr.ReadLine();
}

I only get the line 1 back.
Q: How do I get all lines back?

--
Patrick.
Nov 15 '05 #1
2 3947
Well, first of all, you probably don't want to use ReadLine and WriteLine
since you're only writing one line (the first or last one, I suspect) and
reading that same one line. Instead StreamWriter.Write() the entire
textBox.Text buffer. Then just StreamReader.Read() the entire buffer back
and you'll get your linefeeds and carriage returns.

Pete

"Patrick De Ridder" <00@00.00> wrote in message
news:10***************@news-01.evisp.enertel.nl...
Sorry, this must be very elementary:

When writing line 1 to a textBox,
pressing return
writing line 2 to same tetBox.

Saving that to disc.
using (StreamWriter sw = new StreamWriter ("memo.txt"))
{
sw.WriteLine(textBox1.Text);
}

Reading that from disk.
using (StreamReader sr = new StreamReader ("memo.txt"))
{
textBox1.Text=sr.ReadLine();
}

I only get the line 1 back.
Q: How do I get all lines back?

--
Patrick.

Nov 15 '05 #2
You'll have to loop it until there's no more to be read.

like,

string newLine;
while ((newLine = sr.ReadLine) != null)
{
textBox1.Append(newLine);
}

-vJ

"Patrick De Ridder" <00@00.00> wrote in message
news:10***************@news-01.evisp.enertel.nl...
Sorry, this must be very elementary:

When writing line 1 to a textBox,
pressing return
writing line 2 to same tetBox.

Saving that to disc.
using (StreamWriter sw = new StreamWriter ("memo.txt"))
{
sw.WriteLine(textBox1.Text);
}

Reading that from disk.
using (StreamReader sr = new StreamReader ("memo.txt"))
{
textBox1.Text=sr.ReadLine();
}

I only get the line 1 back.
Q: How do I get all lines back?

--
Patrick.

Nov 15 '05 #3

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

Similar topics

2
by: Jeroen van vliet | last post by:
Hello How can i run a query from a mdb database and show it in a datagrid control when i put in a letter in a textbox? for instance. when i type the letter "A" in the textbox i want to run a...
5
by: Steve | last post by:
I have an unbound combobox in the form header of a continuous form. The selection in the combobox sets the where clause in a querydef which determines QryPFrmInventoryManagement. The following code...
0
by: Paul Rees | last post by:
I am wondering if anyone has encountered a similar problem to the one that I am having. I have an ASP.NET page which has a table and a dropdownlist that was added at design time. The majority of...
11
by: Joe | last post by:
Hello All, I have an ASP.NET page with one Textbox (SearchTextBox) and one ImageButton (SearchButton) server controls. The user can type search text in SearchTextBox and click SearchButton and...
2
by: | last post by:
Hi everyone, I have a form with a combo box on it. When you select a value (a PO#) from the combo box, the bound field is the indexID of the selected PO. On the same form, I have a text box...
6
by: Drum2001 | last post by:
I have a database where I need to query multiple items. Is it possible to run a query based on a textbox where the information is delimited by a comma. Example: Show me all names where...
3
by: DHarris | last post by:
I created a continuous form in Access2003 based on a query that users review customers and once reviewed clicks on a command button that executes an append query to update a table of the reviewed...
3
by: Richard | last post by:
How is the result of query placed in a unbound textbox ? Suppose CriteriaLookups has columns TableName, KeyColumn, KeyValue, DataColumn Foo,x,11,xhat Bar,z,3,xyzzy And
0
by: mamun | last post by:
Hi All, I have the following situation. I have 10 rows in a form. In each row there are six textbox controls. The users can enter any number of rows of records (either none or upto 10). I...
1
by: viral123 | last post by:
Hi all I am using Crystal report and I am running my report successfully for my query but I want to make my query for one specific date. I want to get the date value from the textbox value. ...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.