I'm having problems with getting a rich text box control in vb.net to automatically wrap text to a new line when text is "loaded" from a text or rich text file that was created with an editor such as wordpad. Both the multiline and wordwrap properties are set to true. Also the RightMargin property is set to the width of the rich text box control minus 20.
It seems as though the word wrap function only works when I'm typing text into the rich text box. But I need it to work when I'm loading text from a file in the format of .rtf or .txt that was created with a text editor such as notepad or wordpad. Any suggestions?
Re: rich text box control, word wrap and loadfile?
rtbMain.LoadFile(ofdMain.FileName, RichTextBoxStreamType.RichText)
'The textfile is being loaded using the FileName property of an open file dialog box.
I have no ideal how to attach a file in a forum. I'm new to this new forum stuff.
Re: rich text box control, word wrap and loadfile?
I figured out how to attach a document. This is a sample document. When I load this file into a rich text box control, the text contained in the file doesn't wrap to the next line like it is suppose to. Attached also is the code for the entire application I'm working on. It's not polished yet, I'm still working on it.
Last edited by syntonix; May 1st, 2009 at 02:37 AM.
Re: rich text box control, word wrap and loadfile?
My first question is why are you specifying that the file be loaded as rich text when the file is plain text? I don't know whether that's causing your problem but that would be the first thing to try.
Re: rich text box control, word wrap and loadfile?
Because I want the user to be able to use "rich text formatting" such as changing the color of text, using italic and etc. If I have a plain text file, then I can't use rich formatting.
Re: rich text box control, word wrap and loadfile?
But your file contains plain text, so it's obviously not an RTF file. How you load the file makes no difference to what the RichTextBox can do. You can load plain text and then apply formatting to it, but you must obviously then save it as an RTF file afterwards to keep that formatting.