RichTextBox Hangs Application

G

Guest

I am getting an unhandled system exception while writing to a RichTextBox. The process may run for a few hours or days before the error is generated
The message is "Cannot access a disposed object named RICHTEXTBOX." A check of the stack trace indicates the error is from the DLL that controls writing to the RTB. The form has not been closed and the line of code referenced is in a catch block that writes any error to this form's RTB (named rtbProgress)
The same code using a TextBox does not produce the error, but I lose the bold formatting options for presenting the data
I am just wodering if the RichTextBox is not the most stable of controls to use in a Windows form application
Ke

Sample code
public void ProgressEntry(String sNewEntry

tr

int iSize = this.rtbProgress.Text.Length; // limit size of string to allowed progress box siz
StringBuilder sb = new StringBuilder(iSize)
sb.Append(@"{\rtf1\ansi ")
sb.Append(@sNewEntry + @" \par ")
sb.Append(this.rtbProgress.Rtf + @"\b0 }")
this.rtbProgress.Rtf = @sb.ToString()

catch (Exception e

rtbProgress.Rtf = e.Message + @"\par "; /// Line reporting erro

}
 
J

james

Ken,

There are issues with this control. I'm not sure exactly what your trying
to do
with it though, so I may be off topic here. If you simply want to append
rtf, you can use the clipboard in memory with another in memory rich text
box
to do a copy paste. This does work in our system. But if you want to get
into the rtf and do more complex things, you may run into trouble.
I have seen rtf on our system loose all formatting (bold,font,color) when
we place it on a tab control and switch tabs and come back, our formatting
is gone. Really strange.


JIM

KenH said:
I am getting an unhandled system exception while writing to a RichTextBox.
The process may run for a few hours or days before the error is generated.
The message is "Cannot access a disposed object named RICHTEXTBOX." A
check of the stack trace indicates the error is from the DLL that controls
writing to the RTB. The form has not been closed and the line of code
referenced is in a catch block that writes any error to this form's RTB
(named rtbProgress).
The same code using a TextBox does not produce the error, but I lose the
bold formatting options for presenting the data.
I am just wodering if the RichTextBox is not the most stable of controls
to use in a Windows form application.
 
G

Guest

James

Thanks for responding
I found an old post describing the same error - but no fix. For now I am using a textbox instead of the RTB. I'll miss having the error messages stand out when I check the monitor for a quick status report, but I won't miss the hangs. I am leaving them on the other child forms that are not as busy

Ken
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top