473,387 Members | 1,574 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 3131
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....
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.