473,698 Members | 2,588 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 2682
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
8570
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
30334
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
14776
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
16163
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
5628
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
4104
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
2000
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
5368
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
1956
by: Eng Teng | last post by:
How to control size of length in richtexbox per line ? Regards, Tee
0
8609
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
9169
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...
1
8899
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
7738
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
6528
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
5861
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
4371
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...
2
2335
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2007
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.