sairam

sairam

  • NA
  • 69
  • 0

richtextbox text appending

Jan 9 2009 1:14 PM

Hi

My richtextbox contains the following.

line 1: some text

line 2: image

-----

----

-----

line -7: text

line 8: Image

 

now i want to add some text at line 5 by clcikcing a button. When i press this button text gets added. I am Using a function to add a text at the given cursor position.

void appendtext_to_cursor_position(RichTextBox rtf, String str, int positiontoinsert)

{

int CurrentCeret = rtf.SelectionStart + str.Length;

rtf.Select(positiontoinsert, rtf.TextLength - positiontoinsert);

str = str + rtf.SelectedText ;            /////////// Problem lies here  rtf. selected text is selecting only text     but   not the image. I tried with selected RTf but did not work///////////

rtf.SelectedText = String.Empty;

rtf.AppendText(str);

rtf.SelectionStart = CurrentCeret;

return;

}

 

My Problem is , the text is getting added correctly. But the image after the text that is at Line 8 is getting disappeared.

i have mentioned where the problem is, in the code. but i donno how to correct it.Please help me