XAF ExportController Custom ExportAction Items

 ChoiceActionItem item1 = exportController.ExportAction.Items.FindItemByID("DOCX File"); // 大写第一个单词

 ChoiceActionItem item = exportController.ExportAction.Items.Find(ExportTarget.Xls); // 用枚举来查找

附上完整的ViewController代码:

  public partial class MExportController : ViewController
    {
        public MExportController()
        {
            InitializeComponent();
            // Target required Views (via the TargetXXX properties) and create their Actions.
            TargetViewType = ViewType.ListView;
            TargetObjectType = typeof(ProjectTask);
        }

        private ExportController exportController;

        protected override void OnActivated()
        {
            base.OnActivated();
            // Perform various tasks depending on the target View.
            exportController = Frame.GetController<ExportController>();
            if (exportController != null)
            {
                exportController.ExportActionItemsCreated +=
                    new EventHandler<EventArgs>(exportController_ExportActionItemsCreated);
            }
        }

        private void exportController_ExportActionItemsCreated(object sender, EventArgs e)
        {
            //  // 把xls导出的格式放到第一个位置上
            //  if (exportController.ExportAction.Items.FirstActiveItem != null)
            //  {
            //      if (((ExportTarget)exportController.ExportAction.Items.FirstActiveItem.Data) !=
            //ExportTarget.Xls)
            //      {
            //          ChoiceActionItem item = exportController.ExportAction.Items.Find(ExportTarget.Xls);
            //          exportController.ExportAction.Items.Remove(item);
            //          exportController.ExportAction.Items.Insert(0, item);
            //      }
            //  }
            
            if (exportController.ExportAction.Items.Count > 0)
            {
                var dd = exportController.ExportAction.Items.FindItemByID("DOCX File"); // 测试获取,大写第一个单词                
            }
        }

        protected override void OnViewControlsCreated()
        {
            base.OnViewControlsCreated();
            // Access and customize the target View control.
        }

        protected override void OnDeactivated()
        {
            // Unsubscribe from previously subscribed events and release other references and resources.
            base.OnDeactivated();

            if (exportController != null)
            {
                exportController.ExportActionItemsCreated -=
                   new EventHandler<EventArgs>(exportController_ExportActionItemsCreated);
            }
        }
    }

 参考连接:https://docs.devexpress.com/CoreLibraries/DevExpress.XtraPrinting.ExportTarget

XAF ExportController Custom ExportAction Items

上一篇:打造超完美主页?20个主页设计技能你不容错过


下一篇:一文看懂String类中的常用方法