Click here to Skip to main content
15,908,906 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
1. We have intgrated teleriks wpf control in winform
2. Now we want to insert rtf file from winform to wpf window's radrichtextbox.
3. I tried to send filename from constructor but it causes new instance wpf window created.but can't succeed.
4. So I directly tried to insert file stream from winform to existing instance of wpf window but it applied to starting position.here is code on winform
---------------------------
C#
RadDocument raddoc = new RadDocument();
RtfFormatProvider provider = new RtfFormatProvider();
String abc = lblsnippetpath.Text;
var filePath = Environment.ExpandEnvironmentVariables(abc);            
using (Stream stream = new FileStream(filePath, FileMode.Open))
{
   DocumentPosition startPosition = objbizsop.rch.Document.CaretPosition;
   raddoc = provider.Import(stream);                  
   raddoc.Selection.SelectAll();                                      
   DocumentFragment fragment = raddoc.Selection.CopySelectedDocumentElements();
   objbizsop.radRichTextBox1.Document = raddoc;                  
   raddoc.InsertFragment(fragment, objbizsop.radRichTextBox1.Document.CaretPosition);
}
objbizsop.Show();

-----------------
here objbizsop is instance of wpf window where radrichtextbox is kept.
Please give me idea .
Here is steps how process runs
a. wpf window calls winform
b. winform opens file and insert into wpf window
but it is applied at initial position .I want cursor position.
Posted
Updated 30-Dec-13 14:15pm
v3

1 solution

I have got solutions
I put following code on wpf window before calling winform
C#
this.radRichTextBox1.Document.CaretPosition.MoveToCurrentLineEnd();
           this.radRichTextBox1.Focus();
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900