Results 1 to 7 of 7

Thread: rich text box control, word wrap and loadfile?

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2009
    Location
    Milwaukee, Wisconsin
    Posts
    4

    rich text box control, word wrap and loadfile?

    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?

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: rich text box control, word wrap and loadfile?

    Can you attach an example of a file that doesn't work and also post the exact code you're using to load it? We can then test it exactly as you are.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2009
    Location
    Milwaukee, Wisconsin
    Posts
    4

    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.

  4. #4

    Thread Starter
    New Member
    Join Date
    May 2009
    Location
    Milwaukee, Wisconsin
    Posts
    4

    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.
    Attached Files Attached Files
    Last edited by syntonix; May 1st, 2009 at 02:37 AM.

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    New Member
    Join Date
    May 2009
    Location
    Milwaukee, Wisconsin
    Posts
    4

    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.

  7. #7
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    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.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width