Results 1 to 4 of 4

Thread: Open large rich text file smoothly

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Dec 2009
    Posts
    99

    Angry Open large rich text file smoothly

    Hi
    If there is any way to open large rtf files in rich text text box ?
    when i try to open a large rtf file in rich text box it halt the system unlike windows word pad . win word pad open file smoothly may be read line by line how it possible in vb.net?

  2. #2
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Open large rich text file smoothly

    Hey,

    How large a file are we talking about here?

    Can you show the code that you are currently using?

    Gary

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Dec 2009
    Posts
    99

    Re: Open large rich text file smoothly

    vb Code:
    1. With OpenFileDialog1
    2.             'Set the Filter Text to set the open file types
    3.             .Filter = "Urdu Files (*.urdu)|*.urdu|" & _
    4.                                "Rich Text Files (*.rtf) |*.rtf"
    5.  
    6.             'Pick Text Files to begin with
    7.             .FilterIndex = 1
    8.  
    9.             'The Caption of your OpenDialog
    10.             .Title = "Choose a File To Open....."
    11.  
    12.             'Ensure we only get back valid filenames
    13.             .CheckFileExists() = True
    14.             .CheckPathExists = True
    15.             .ValidateNames = True
    16.             .DereferenceLinks = True
    17.  
    18.             'Set the starting dir
    19.             ' .InitialDirectory = "c:\"
    20.  
    21.             'Show the OpenDialog
    22.             .ShowDialog(Me)
    23.             TextBox1.AutoWordSelection = True
    24.             TextBox1.ScrollBars = RichTextBoxScrollBars.Vertical
    25.             TextBox1.WordWrap = True
    26.             If .FileName = "" Then GoTo line
    27.             TextBox1.LoadFile(.FileName, _
    28.                     RichTextBoxStreamType.RichText)
    29.  End With

    File Is Large Up to 5 MB
    Last edited by hackerspk; Jan 8th, 2010 at 07:00 AM.

  4. #4
    PowerPoster gep13's Avatar
    Join Date
    Nov 2004
    Location
    The Granite City
    Posts
    21,963

    Re: Open large rich text file smoothly

    Hey,

    I am going out on a limb here (because I have never actually done this), but I suspect you could do the work of loading the file in a BackgroundWorker:

    http://msdn.microsoft.com/en-us/libr...undworker.aspx

    That way, your UI will still be usable by the end user.

    Gary

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