473,738 Members | 8,848 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Insert text in the middle of a formated richtexbox.

I need to merge the content of two richtextboxes.

It can not be accomplished using the RichtTextBox.Te xt field because all
format will be lost. So it has to be done using the RichtTextBox.Rt f field,
but I loose part of it as follows:

private void MergeRtf()
{
// having the RichTextBox controls.

string Rtf = "";
int nInsertIndex = 50;
RichtTextBox1.S electionStart = 0;
RichtTextBox1.S electionLength = nInsertIndex;
Rtf = RichtTextBox1.S elect
RichtTextBox1.T ext = "";

}

Nov 17 '05 #1
1 2688
Reposting this message.

I need to insert text into a richtextbox preserving the existing formating.

It can not be accomplished using the RichtTextBox.Te xt field because all
format will be lost. So, it has to be done using the RichtTextBox.Rt f field,
but I loose part of the content as follows:

private void MergeRtf()
{
// having the RichTextBox controls.

string sRtf = "";
string sInsert = "Insert this text";
int nInsertIndex = 50;
// Selecting richtext before inserting point
RichtTextBox1.S electionStart = 0;
RichtTextBox1.S electionLength = nInsertIndex;

// Adding richtext before inserting point to sRtf
sRtf = RichtTextBox1.S electedRtf;

// Adding inserting text to sRtf
sRtf += sInsert;

// Selecting richtext After inserting point
RichtTextBox1.S electionStart = nInsertIndex + 1;
RichtTextBox1.S electionLength = RichtTextBox1.T extLength - nInsertIndex - 1;

// Adding richtext after inserting point to sRtf
sRtf += RichtTextBox1.S electedRtf;

// Setting the RichTextBox.Rtf field, but it only adds the text before the
//inserting point.
RichtTextBox1.R tf = sRtf;
}

I will appreciate any ideas.

Carlos Lozano
www.caxonline.net

"Carlos Lozano" wrote:
I need to merge the content of two richtextboxes.

It can not be accomplished using the RichtTextBox.Te xt field because all
format will be lost. So it has to be done using the RichtTextBox.Rt f field,
but I loose part of it as follows:

private void MergeRtf()
{
// having the RichTextBox controls.

string Rtf = "";
int nInsertIndex = 50;
RichtTextBox1.S electionStart = 0;
RichtTextBox1.S electionLength = nInsertIndex;
Rtf = RichtTextBox1.S elect
RichtTextBox1.T ext = "";

}

Nov 17 '05 #2

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

Similar topics

20
8579
by: akej via SQLMonster.com | last post by:
Hi, i have table with 15 columns CREATE TABLE . ( PRIMARY KEY , NULL , NULL , NULL , NULL , (50) NULL , NULL
7
30362
by: Paul Gorodyansky | last post by:
Hi, Say I have a text in my TEXTAREA box - 01234567890 I want - using script - insert say "abc" in the middle. Works almost OK in Internet Explorer (with one problem) based on their example at http://msdn.microsoft.com/library/en-us/dnwebteam/html/webteam12032001.asp in the chapter "O Cursor, Where Art Thou".
7
14782
by: tano | last post by:
Hello, I have to insert a char in the middle of a string, I have written two functions but I don't know what is the better? The problem is: if I use malloc() I copy all the string with the new char in the middle every time, with realloc() the part of the string before the position where the char has to be inserted is not changed if realloc returns the same pointer is passed, but if not the string is copied at all the first time, and then...
2
16166
by: Nenad Dobrilovic | last post by:
Hi, can I have two lines with different colors in Windows ListBox control? Thank you in advance, Cheya
20
5641
by: Guadala Harry | last post by:
In an ASCX, I have a Literal control into which I inject a at runtime. litInjectedContent.Text = dataClass.GetHTMLSnippetFromDB(someID); This works great as long as the contains just client-side HTML, CSS, etc. What I want to do is somehow insert a *server control* into the , then set the server control's properties at runtime.
4
4113
by: Al | last post by:
Hi, Is there any way to insert LinkLabel in rich text box? Or hyperlink a text in rich text box? Thanks Al
5
2002
by: S Shulman | last post by:
Hi I am looking for a way to insert formated text from the Rich Text Box to a Word Document That way the user will not have to Re-Format the text Thank you in advance, Shmuel Shulman
3
5378
by: sb Luis | last post by:
I Use the following code to read from MS Word, but I couldent read Formated Text (RTF). How Can I read formated text from MS Word Doc without using clipboard. thanks. Word.ApplicationClass WordApp = new Word.ApplicationClass(); ..... // Let's get the content from the document Word.Paragraphs DocPar = Doc.Paragraphs; // Count number of paragraphs in the file
1
1957
by: Eng Teng | last post by:
How to control size of length in richtexbox per line ? Regards, Tee
0
8788
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
9476
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
9335
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
8210
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
6751
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
6053
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();...
0
4570
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4825
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2745
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.