This example illustrates how to customize the "Insert Merge Field" menu to group merge field names with identical prefixes (Employees and Customers in this example) into submenus. Note that we completely replace built-in InsertMergeFieldItem with a custom one. You can find its implementation in the CustomInsertMergeFieldItem.cs (CustomInsertMergeFieldItem.vb for VB.NET) code file. We are creating a PopupMenu Class instance and populating it with menu items/subitems on the fly. The field names of the datasource are obtained with help of a special DataBindingController class.
Finally, the actual merge field insertion is accomplished in the CustomInsertMergeFieldMenuItem'sOnClick method. Take a moment to look at the Create DOCVARIABLE in code and How to create nested fields programmatically code example to learn more on this subject.
Take note of a CustomInsertMergeFieldItem'sOnClick method. It delegates handling to the regular ShowInsertMergeFieldFormCommand. You can implement and display your own dialog here if necessary.
Here is a screenshot that illustrates a sample application in action:
Question Comments
Added By: Hampus Nilsson at: 5/12/2014 5:20:56 AM
How is this done for the WPF based version of RichEdit?
Added By: Yulia (DevExpress Support) at: 5/12/2014 7:57:52 AM Hi Hampus,I have created a separate ticket on your behalf: How to customize the "Insert Merge Field" menu. We will answer you there.