I was wondering if there was any way to underline the text of a string...
Application: For right now I am outputing a bunch of strings into a message string to display in a message box. Later I will be outputting to a text file. I have searched the MSDN Lib to no avail; if someone could point me in the right direction, that would be great. Can you use HTML code in VC#
Thanks
Thom

Underline text
yoshikatsu
you can write to an rtf/doc file via a streamwriter HOWEVER, it may not write correctly to comply with the standard formatting/format of a word/RTF file. To do this, a richtextbox control has the LoadFile and Save methods to correctly write to the RTF file in the correct format.
In order to make a correct/proper rtf file, you need to know about the rtf encoding etc...
connect2sandeep
Any thoughts
Should I change all the textbox controls to RichTextBox Controls
Thanks Tom
Prabhu000
Thanks Thomas
Richard Proudfoot
Thanks
Tom
Ross Watson
Any Ideas
Should I change all the Text box controls to richtextbox controls
Thanks
Thomas
I.H
Thanks
Tom
Murtaza Ali
rwbta
Tom Janssen
that's correct it will overwrite it by default. Fortunately in one of the overloads for the SaveFile(), you can use a stream to append to the stream. The best way perhaps would be to use a Memorystream to append to the stream then finally when wanting to actually write the file, just read everything from the stream and write it to file.
When loading, pretty much the same thing except you load the entire file into the memorystream.
here is an example on how to achieve the appending:
http://msdn2.microsoft.com/en-us/library/ms160336.aspx
Hope this gives you some steps!
Jim Ward
Currently this is my code :
richTextBox1.SaveFile(System.Environment.GetFolderPath
(System.Environment.SpecialFolder.Personal)+ @"\Testdoc.rtf");
which saves a file called Testdoc.rtf but if you click save once, then change the text and save again it doesn't append it just overwrites it. How can you just append it
Thanks Thomas
ravindra_pn
it will keep appending to the stream until you finally want to commit changes to the file, then read the entire stream into the file.
You of course need to read the entire file into the memorystream, when loading, so it can continue on appending to the stream. You need to of course as stated in the doc/shown by example, make the memorystream a global scope so other methods can access it through the class. Make sure you clear out/create a new instance of the memorystream when loading a file to prevent it from appending to the previous file.
I tried using a FileStream to append to the file but did not work unfortunately. You can do it, by using the memorystream and the example in the doc
c_shah
quiklearner
hang on.... I re-read your post
this is natural. If you save the file, then delete text and add the text again (Different text) then yes it will "overwrite" it, its natural. However if you append to a loaded file in the RTB control and append to it, and save it, it will save the entire thing as is displayed in the RTB control....this is not what you are after
so if I loaded a file and it had "hi" on it, then I added to it at the end "how are you" and saved it, you should get the file to read "hi how are you"
if you replaced "hi" with "hey" and saved it, it will say "hey" as that is what was entered....
whatever is written into the richtextbox control is saved as is to the file
varunsagii
"Would it just be creating a newform and just calling an instace of it from my app "
Yes, You have to Create a Form to be a message, setting proprties like, ControlBox = false; TopMost=true; StartPostion = CentreParent etc.
You have to work with Dialog result and assign the values aprpriately on clicking on different buttons.
"Also can you use streamwriter to write to an rtf or doc file"
Yes! you can do it.