By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,761 Members | 1,183 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,761 IT Pros & Developers. It's quick & easy.

RichTextBox Hangs Application

P: n/a
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

}
Nov 15 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
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" <an*******@discussions.microsoft.com> wrote in message
news:DE**********************************@microsof t.com...
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. Ken

Sample code:
public void ProgressEntry(String sNewEntry)
{
try
{
int iSize = this.rtbProgress.Text.Length; // limit size of string to allowed progress box size 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 error
}
}

Nov 15 '05 #2

P: n/a
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
Nov 15 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.