private void PrepareMergeTableByFieldNames(NewFieldsForm newFieldsForm)
        {
            DataTable dataTable = new DataTable("MergeTable");

            foreach (string fieldName in newFieldsForm.FieldNames)
            {
                dataTable.Columns.Add(fieldName);
            }

            CreateDefaultData(dataTable);
            richEditControl1.Options.MailMerge.DataSource = dataTable;
        }
        private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e)
        {
            using (NewFieldsForm newFieldsForm = new NewFieldsForm()) {
                PrepareFieldNamesByMergeTable(newFieldsForm);

                if (newFieldsForm.ShowDialog() == DialogResult.OK)
                {
                    PrepareMergeTableByFieldNames(newFieldsForm);
                }
            }
            ribbonControl1.SelectedPage = ribbonControl1.Pages["Mailings"];
        }
        private void PrepareFieldNamesByMergeTable(NewFieldsForm newFieldsForm)
        {
            DataTable dataTable = (DataTable)richEditControl1.Options.MailMerge.DataSource;

            string[] fieldNames = new string[dataTable.Columns.Count];

            for (int i = 0; i < fieldNames.Length; i++)
            {
                fieldNames[i] = dataTable.Columns[i].ColumnName;
            }

            newFieldsForm.FieldNames = fieldNames;
        }