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

Saving dynamically created RichTextBox text

P: n/a

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

this.boxen.richTextBox1.Name = "box" + this._pageCount.ToString();
this._pageCount += 1;

this._richTextBoxToFileName[this.boxen.richTextBox1.Name] =

How can I save the contens of the RichTextBox in the selected tabPage.
Can I some how choose the RichTextBox when I know it's name or name the
RichTextBox that i want to save at runtime??


Apr 10 '06 #1
Share this Question
Share on Google+
3 Replies

P: n/a
ritch text boxes expose a feilt called "rtf".
The text in this feild is stores all the rich text in the controll.

also your richtextbox has load and save functions...


Apr 10 '06 #2

P: n/a
The text that is loaded into the RichTextBoxes is
RichTextBoxStreamType.PlainText. The problem is that my save function
doesn't recognize which tab containing one of the RichTextBoxes is
selected. When I try to save the text like this, my save function saves
the RichTextBox that was opened last, and not he one in the

RichTextBoxStreamType.PlainText) ;

I do know wich is selected by doing the following:

string fileNameToSave =

So, how do I save the text from the selected tabPage??

Apr 10 '06 #3

P: n/a
This is all of memory so don't shot me if there is a problem.

your tab box control has a "selectedtab" property. Its a reference to
the currently selected tab page. This items has a "controls"
collection. This stores all the controls in the tab.

so something like...

foreach (control c in myTabControl.selectedtab.controls)
if(c is richTextBx)
note the above code is just mey thyping out roughly for you it is not
syntaticly correct and you will need to sort it out yourself to make it

Hope this helps


Apr 11 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.