Hello Candra,
Here is a code snippet that illustrates how to create a DOCVARIABLE field with nested MERGEFIELD:
[C#]string includeDetailField1 = "DOCVARIABLE Product \"\" "; string includeDetailField2 = "MERGEFIELD SupplierID"; richEditControl1.Document.Fields.Add(richEditControl1.Document.Range.Start, includeDetailField1); richEditControl1.Document.Fields.Add(richEditControl1.Document.CreatePosition(22), includeDetailField2);
I hope you will find this information helpful.
Thanks,
Alessandro.
Hello Candra,
Utilize the RichEditControl.Document.InsertParagraph() method (see SubDocument.InsertParagraph Method ) for this purpose.
Thanks,
Alessandro.
Hi, it's works fine with your solution..
For the add, it can be solved with richEditControl1.Document.AppendText(System.Environment.NewLine)
For another issue,
How about if I have 2 key field for the detail.
For example. The header has EmployeeId, and the detail has 2 key field EmployeeId and EmpSeq?
How can DocVariable can be written with this issue?
Thanks...
Best regards,
Candra
Hello Candra,
Utilize the same approach for this purpose:
[C#]string includeDetailField1 = "DOCVARIABLE Product \"\" \"\" "; string includeDetailField2 = "MERGEFIELD EmployeeId"; string includeDetailField3 = "MERGEFIELD EmpSeq"; richEditControl1.Document.Fields.Add(richEditControl1.Document.Range.Start, includeDetailField1); richEditControl1.Document.Fields.Add(richEditControl1.Document.CreatePosition(22), includeDetailField2); richEditControl1.Document.Fields.Add(richEditControl1.Document.CreatePosition(49), includeDetailField3);
Thanks,
Alessandro.
Hi Alessandro,
It's works fine for the solution that you give it to me, thanks.
But I have another issue again.
I tried to save it into database :
MemoryStream ms = new MemoryStream();
RichEditControl1.SaveDocument(ms, DocumentFormat.OpenDocument);
Byte[] array = ms.ToArray();
The variable array I saved in database with sqldbtype = Varbinary(max)
But when I tried to load it with :
MemoryStream ms = new MemoryStream(array);
RichEditControl1.LoadDocument(ms, DocumentFormat.OpenDocument);
The fields change like this in the document :
{ DOCVARIABLE Product " MERGEFIELD EmployeeId <<EmployeeId>>" }
When I display it.
Is there something that I missing ?
Thanks.
Is your intention to post an answer to your own question?
- If so, then proceed.
- If you simply wanted to post additional information, ask for further clarification, or to just say "Thanks!", please click Leave a Comment.
- If you wish to edit your original question, please use the Edit button in the Toolbox at the top right corner of that entry.
Facebook
Twitter
Google+