472,371 Members | 1,531 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,371 software developers and data experts.

RichTextBox Hangs Application

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
2 3044
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Terminal882003 | last post by:
Hi, I have a problem in my application(C#) if I using RichTextBox to continuously display a series of text messages (using method AppendText()). When application is running, it will stop at some...
0
by: nouno | last post by:
I am trying to spell check a richtextbox. Through code (shown below) I save the contents of the richtextbox to a rtf file, open the rtf file in Word, spell check it, save it, and then load the ftf...
5
by: user | last post by:
Hello When i add new lines of text to my RichTextBox, and when vertical scroll bar appear (there is more text than RichTextBox can display), RichTextBox always display "the oldest text" (vertical...
2
by: Ludovic SOEUR | last post by:
Suppose I have a .Net C# Winforms App with a RichTextBox control and I want to provide an option for the user to open the Rtf in Word, edit it in Word and get the edited value back to my C# app...
1
by: tulasi | last post by:
I am placing textbox controls and combo box controls on richtext box and 2 command buttons on form control. after executing the application i'll place some text into textbox controls and select a...
3
by: AxOn | last post by:
Hi, I have an application with a Save function. I want to be able to have several tabs(each containing a RichTextBox, created at runtime) open in a tabControl and save the text from each...
6
by: Alexander Widera | last post by:
hello, if i start a program (an exe-file) with Process.Start(...) I don't have the required permissions that the programm needs (i could start the programm but the program needs special rights)....
5
by: Ludwig | last post by:
Goal: text that is pasted in a RichTextBox control has to be formatted (keywords should get another forecolor/style). My first attempt to format the text was the traditional approach of setting...
1
by: Mathias Weyel | last post by:
Hi Group! I have a simple GUI featuring a RichTextBox and a Button. On Button click, I start a BackgroundWorker that performs a query on the database firing a ProgressChangedEvent for every row....
2
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and efficiency. While initially associated with cryptocurrencies...
0
by: Naresh1 | last post by:
What is WebLogic Admin Training? WebLogic Admin Training is a specialized program designed to equip individuals with the skills and knowledge required to effectively administer and manage Oracle...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and credentials and received a successful connection...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific technical details, Gmail likely implements measures...
1
by: Matthew3360 | last post by:
Hi, I have been trying to connect to a local host using php curl. But I am finding it hard to do this. I am doing the curl get request from my web server and have made sure to enable curl. I get a...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the synthesis of my design into a bitstream, not the C++...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand. Background colors can be used to highlight important...
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS starter kit that's not only easy to use but also...
2
by: Ricardo de Mila | last post by:
Dear people, good afternoon... I have a form in msAccess with lots of controls and a specific routine must be triggered if the mouse_down event happens in any control. Than I need to discover what...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.