zoukankan      html  css  js  c++  java
  • [原] XAF How to Edit multiple objects in a ListViewAndDetailView

    2014年好久没有更新Blog了,工作调换了,很少用XAF,但还是很关注XAF的发展和学习,对中国的中小企业数据管理软件开发真的太实用了!!

    功能比较简单,但很实用,直接上图和代码!

    ListView處於ListViewAndDetailView編輯模式

    using System;
    using System.Linq;
    using System.Text;
    using DevExpress.ExpressApp;
    using DevExpress.Data.Filtering;
    using System.Collections.Generic;
    using DevExpress.Persistent.Base;
    using DevExpress.ExpressApp.Utils;
    using DevExpress.ExpressApp.Layout;
    using DevExpress.ExpressApp.Actions;
    using DevExpress.ExpressApp.Editors;
    using DevExpress.ExpressApp.Templates;
    using DevExpress.Persistent.Validation;
    using DevExpress.ExpressApp.SystemModule;
    using DevExpress.ExpressApp.Model.NodeGenerators;
    using DevExpress.Xpo;
    using DevExpress.XtraEditors;
    using DevExpress.ExpressApp.Win.Templates;
    
    namespace SimpleProjectManager.Module.Controllers
    {
        // For more typical usage scenarios, be sure to check out http://documentation.devexpress.com/#Xaf/clsDevExpressExpressAppViewControllertopic.
        public partial class EditerPlusieursLignesListViewController : ViewController<ListView>
        {
            public EditerPlusieursLignesListViewController()
            {
                InitializeComponent();
                RegisterActions(components);
                // Target required Views (via the TargetXXX properties) and create their Actions.
            }
            protected override void OnActivated()
            {
                base.OnActivated();
                if (View == null)
                    return;
    
                if(((ListView)View).EditView == null)
                   return;
    
                if( ((ListView)View).EditView.Items==null)
                    return;
    
                foreach (ViewItem item in ((ListView)View).EditView.Items)
                {
                    item.ControlCreated += item_ControlCreated;
                }
            }
    
            void item_ControlCreated(object sender, EventArgs e)
            {
                ViewItem item = (ViewItem)sender;
                if (item.Control.GetType() == typeof(NestedFrameTemplate)) return;
                ((BaseEdit)item.Control).EditValueChanged += (sender2, e2) =>
                {
                    if (View != null && View.SelectedObjects.Count > 1)
                    {
                        foreach (XPBaseObject xpo in View.SelectedObjects)
                        {
                            xpo.SetMemberValue(item.Id, ((BaseEdit)sender2).EditValue);
                        }
                    }
                };
            }       
        }
    }
  • 相关阅读:
    学习PyQt5(二):PyQt5布局管理
    学习PyQt5(一):安装PyQt5以及在PyCharm上配置PyQt5
    Day037--Python--线程的其他方法,GIL, 线程事件,队列,线程池,协程
    Day036--Python--线程
    Day035--Python--管道, Manager, 进程池, 线程切换
    Day034--Python--锁, 信号量, 事件, 队列, 生产者消费者模型, joinableQueue
    Day033--Python--进程
    Day032--Python--操作系统, process进程
    Day30--Python--struct, socketserver
    Day29--Python--缓冲区, 粘包
  • 原文地址:https://www.cnblogs.com/Tonyyang/p/4082914.html
Copyright © 2011-2022 走看看