473,785 Members | 2,557 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Saving dynamically created RichTextBox text

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:

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

this._richTextB oxToFileName[this.boxen.rich TextBox1.Name] =
openFileDialog1 .FileName;

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??

Thanks!

Apr 10 '06 #1
3 2188
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...

-dm

Apr 10 '06 #2
The text that is loaded into the RichTextBoxes is
RichTextBoxStre amType.PlainTex t. 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
selectedTab.

this.boxen.rich TextBox1.SaveFi le(fileNameToSa ve,
RichTextBoxStre amType.PlainTex t) ;

I do know wich is selected by doing the following:

string fileNameToSave =
(string)this._r ichTextBoxToFil eName[tabControl1.Sel ectedTab.Name];

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

Apr 10 '06 #3
This is all of memory so don't shot me if there is a problem.

your tab box control has a "selectedta b" 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.se lectedtab.contr ols)
if(c is richTextBx)
((richtextbox)c ).save(....)
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
compile.....

Hope this helps

-dm

Apr 11 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
1899
by: gogaz | last post by:
Hello, I am facing one strange problem. I am using RichTextBox control in my VB6.0 application and have provided one button giving functionality to set bullets on the selected text. When i type and set bullets on some text and save the document, it is displaying everything ok. But when i open the saved file again I notice some small dots in the line before and after the bulleted text.
1
2585
by: vanvee | last post by:
Hi I have a user control that contains a RichTextBox in vb.net. In my program, I create multiple instances of this control (with the RichTextBox being in each one), that appear one above the other on a panel. The problem is that each control may have varying amounts of data, and so each RichTextBox (within each control) needs to size to fit the amount of text within that RichTextBox. I've tried multiplying the size of a single line...
4
7547
by: JRB | last post by:
Hi, I've got a bunch of text put onto a richTextBox with a StreamWriter. Every now and then I insert a '\n' character for a new line. It displays properly in the richTextBox with the \n character moving the text down to the next line. The problem is that I have it set up so when the user clicks a button I want to be able to save everything on the richTextBox to a file. It works properly, but when I view the text file with Notepad, the \n...
1
5457
by: TheBinar | last post by:
Hi I have a user control that contains a RichTextBox in vb.net. In my program, I create multiple instances of this control (with the RichTextBox being in each one), that appear one above the other on a panel. The problem is that each control may have varying amounts of data, and so each RichTextBox (within each control) needs to size to fit the amount of text within that RichTextBox. I've tried multiplying the size of a single line...
0
2390
by: AxOn | last post by:
Hi! I'm having trouble creating a save funktion. How can I save the contens of a new richTextBox that is created from an "external" class file? The open funktion looks like this: public void openFile() { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Title = "Select a Text File";
8
3286
by: AxOn | last post by:
Hi, How can i save the specific RichTextBox in the selected tab if i have several tabs with RichTextBoxes in? The application is a text editor type program and when i try to save the most recently opened text file in the rich text box my application saves that file over the other files?? Can i some how index the new RichTextBoxes so that only the text in the selected RichTextBox is saved??
1
1627
by: theJonster | last post by:
Hi, I have created a page with a list of items and next to these items are comment boxes and check boxes which were dynamically created like this: check = new CheckBox(); check.ID = "Chk" + checkcount; if (dr.ToString() == "True") {
0
1402
Ajm113
by: Ajm113 | last post by:
Contributing To: Saving RichTextBox from Tab Control Ok, I have a question what would I use if I wanted to do something like a paste function in a Rich Text Box using the code on that thread? Thanks, Ajm113.
1
1271
by: =?Utf-8?B?TWFya19C?= | last post by:
I have an unpredictable number of RichTestBoxes, stored in a generic list, that are created at runtime. Currently, I am saving these controls to a file by saving each attribute of each box in string form using a streamwriter. Later, these attributes are read from the file with a streamreader and the controls are recreated. It seems like a cumbersome, inelegant, and inefficient way to save. Is there another way of saving the entire...
0
9647
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9485
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
10356
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
10161
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...
0
8986
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
7506
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
5523
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3662
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2890
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.