473,395 Members | 1,706 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,395 software developers and data experts.

StreamWriter Class Question...

I am trying to pass a text stream from streamwriter class to a richtextbox,
or textbox doesn't matter which one. I have the file write version working
fine such as:

x.streamwriter = System.IO.File.CreateText("C:\text.txt")
Anyway to write to a textbox or rtf rather than file... ?

Thanks in advance...

Anthony Nystrom
Nov 21 '05 #1
1 1615
Use a StringWriter instead of a StreamWriter. StringWriter has a
ToString() method you can call to set the text in the textbox.

textBox.Test = stringWriter.ToString()

You can't bind a StringWriter to a TextBox though--you have to set the
TextBox.Text property manually. You can create a custom writer class
that adds a binding enabled Text property and then you can bind your
custom class to a TextBox (I think you just need a Text property and a
TextChanged event).

If the underlying function needs to work with both a StreamWriter and
a StringWriter, then declare the property/argument/variable as type
TextWriter.

HTH,

Sam
On Thu, 30 Dec 2004 20:33:01 -0800, Anthony Nystrom
<An************@discussions.microsoft.com> wrote:
I am trying to pass a text stream from streamwriter class to a richtextbox,
or textbox doesn't matter which one. I have the file write version working
fine such as:

x.streamwriter = System.IO.File.CreateText("C:\text.txt")
Anyway to write to a textbox or rtf rather than file... ?

Thanks in advance...

Anthony Nystrom


Nov 21 '05 #2

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

Similar topics

4
by: Majed | last post by:
Hi , all I'm trying to write unicode to a file for another app (not developed with vs2003) to read it. I used StreamWriter with unicode encoding.but I was surprised that the streamwriter adds FFFE...
4
by: rex64 | last post by:
I am getting an error message and I have not been able to figure hot how to fix it. I have done some research with no answers yet. I found this code that may help? Not sure what to do with it....
2
by: David Buchan | last post by:
I have written a program to write some text to a file. Currently, if the file already exists, the program simply overwrites it. What I'd like to do, is have the program ask me if I wish to...
6
by: Don | last post by:
I'm having problems working with a streamwriter object. After closing the streamwriter and setting it to Nothing, I try to delete the file it was writing to, but I always get the following error...
3
by: Mads Westen | last post by:
Hi, I'm making some changes to my program, because I need to write with Codepage 850. Before I used FileStream, but I found code to use with StreamWriter instead. My problem is, that I don't...
3
by: Rob | last post by:
I have a streamwriter that may get closed. The writer is passed into another class by ref and is consumed there. What can happen is that the writer might get closed by the spawning class. Is...
4
by: Heron | last post by:
Hi, Could someone explain me why the following code doesn't work? The memorystream always remains with length 0. MemoryStream input = new MemoryStream();
1
by: Merk | last post by:
In a 2.0 Windows Forms app... in a static class I have a method named WriteToLocalLog() that writes to a text file on the local machine. I declare a StreamWriter at the class level (not inside...
7
by: Eran.Yasso | last post by:
Hi, In the MSDN the sample doesn't use the close() method. But I know that in most languages you do need to use the close() method after reading and writing to a file. from MSDN: public...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.