翻譯|使用教程|編輯:況魚杰|2021-01-14 14:48:07.287|閱讀 206 次
概述:直接使用可枚舉的業務對象作為數據源來合并模板是TX Text Control Reporting的典型方案之一。
# 界面/圖表報表/文檔/IDE等千款熱門軟控件火熱銷售中 >>
相關鏈接:
TX Text Control .NET for Windows Forms 是一套功能豐富的文字處理控件,它以可重復使用控件的形式為開發人員提供了Word中常用的文字處理功能,對于需要強大且靈活的文檔處理能力的應用程序而言,是理想的選擇。
點擊下載 TX Text Control .NET for Windows Forms X19試用版
直接使用可枚舉的業務對象作為數據源來合并模板是TX Text Control Reporting的典型方案之一。
使用IEnumerable對象作為數據源
MailMerge將集合中對象的所有公共屬性解釋為表列和子表。 IEnumerable類型的屬性會自動實例化為關系,并用于合并塊和嵌套合并塊。考慮以下類結構作為數據源:
以下是代表以上UML類設計的代碼:
public class Invoice { public List<Product> Products { get; set; } public Customer Customer { get; set; } } public class Product { public Product(string Name, Decimal Price) { this.Name = Name; this.Price = Price; } public string Name { get; set; } public Decimal Price { get; set; } }
該模板包含一個名為Products的合并塊。 塊中的合并字段名為“名稱”和“價格”。
以下代碼顯示了如何創建數據源對象以及如何使用MergeObjects啟動合并過程:
Invoice invoice = new Invoice(); invoice.Products = new List<Product>(); invoice.Products.Add(new Product("Apple", 3.55m)); invoice.Products.Add(new Product("Banana", 2.4m)); invoice.Products.Add(new Product("Pineapple", 2.99m)); var invoices = new List<Invoice>(); invoices.Add(invoice); mailMerge1.MergeObjects(invoices);
文章推薦:
TX Text Control系列教程—Windows Forms:創建應用程序
如果您對Text Control感興趣,可以咨詢購買正版授權軟件。
關注慧聚IT微信公眾號 ???,了解產品的最新動態及最新資訊。
本站文章除注明轉載外,均為本站原創或翻譯。歡迎任何形式的轉載,但請務必注明出處、不得修改原文相關鏈接,如果存在內容上的異議請郵件反饋至chenjj@fc6vip.cn
文章轉載自: