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 = "";
}