473,782 Members | 2,396 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(S tring sNewEntry

tr

int iSize = this.rtbProgres s.Text.Length; // limit size of string to allowed progress box siz
StringBuilder sb = new StringBuilder(i Size)
sb.Append(@"{\r tf1\ansi ")
sb.Append(@sNew Entry + @" \par ")
sb.Append(this. rtbProgress.Rtf + @"\b0 }")
this.rtbProgres s.Rtf = @sb.ToString()

catch (Exception e

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

}
Nov 15 '05 #1
2 3200
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,colo r) when
we place it on a tab control and switch tabs and come back, our formatting
is gone. Really strange.
JIM

"KenH" <an*******@disc ussions.microso ft.com> wrote in message
news:DE******** *************** ***********@mic rosoft.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(S tring sNewEntry)
{
try
{
int iSize = this.rtbProgres s.Text.Length; // limit size of string to allowed progress box size StringBuilder sb = new StringBuilder(i Size);
sb.Append(@"{\r tf1\ansi ");
sb.Append(@sNew Entry + @" \par ");
sb.Append(this. rtbProgress.Rtf + @"\b0 }");
this.rtbProgres s.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
1772
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 point (randomly), the error message is: ********************************* System.NullReferenceException: Object reference not set to an instance of an object.
0
3251
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 file back into the ricktextbox using loadfile. The problem is that the richtextbox seems to remain bound to the rtf file. If I make a change in the richtextbox after spell checking, the changes are successfully saved to the database but if the...
5
13049
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 scrollbar is always rolled to the top). And i want to see "fresh text" (vertical scrollbar should be rolled to bottom position). How can i do that ?
2
6028
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 dynamically (not with an external file). Where should I start? Is there a document explaining this? I read msdn but I did not see exactly what I am looking for thanks,
1
1684
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 value from combo box after entering of all the details i'll click on one of the command buttons then it will save the contents of the controls which i placed on the richtextbox into a file then i'll click on another command button so it will...
3
2188
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 RichTextBox one at a time. The plain text is loaded into the RichTextBoxes via an openFile funktion that creates a new RichTextBox. When the file is opened the name of the new RichTextBox and the name of the file is stored in a Hashtable like so:
6
3386
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). So I added the StartInfo.UserName and Password to the Process. Now the program starts, but it hangs... nothing happens. In the task-manager the process is created, but it doesn't do anything - no cpu-load and no change of memory-usage. What...
5
1507
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 SelectionStart and SelectionLength, and then setting the SelectionColor/SelectionFont. This works fine for small updates, but when large amount of text is pasted it takes seconds to format the whole text; sometimes it just hangs. This is...
1
1558
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. The corresponding event handler appends the row to the RichTextBox. This works quite fine, but if I click into the TextBox while the BackgroundWorker is running, the TextBox gets blank and the GUI hangs until the BackgroundWorker has finished....
0
9480
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10313
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10146
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10080
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7494
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6735
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2875
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.