1.在列表编辑器中

XAF中实现树形属性或树形编辑

2.在属性编辑器中

XAF中实现树形属性或树形编辑

3.实现代码如下

代码
using System;
using System.ComponentModel;

using DevExpress.Xpo;
using DevExpress.Data.Filtering;

using DevExpress.ExpressApp;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;

namespace XSolution1.Module
{
   [DefaultClassOptions]
    
public class Employee : BaseObject
    {
        
public Employee(Session session) : base(session) { }

        
private string _Name;
        
public string Name
        {
            
get
            {
                
return _Name;
            }
            
set
            {
                SetPropertyValue(
"Name"ref _Name, value);
            }
        }

        
private string _Note;
        
public string Note
        {
            
get
            {
                
return _Note;
            }
            
set
            {
                SetPropertyValue(
"Note"ref _Note, value);
            }
        }

        
private Department _Department;
        
public Department Department
        {
            
get
            {
                
return _Department;
            }
            
set
            {
                SetPropertyValue(
"Department"ref _Department, value);
            }
        }
    }

}

 

 

代码
using System;
using System.ComponentModel;
using DevExpress.Xpo;
using DevExpress.ExpressApp;
using DevExpress.Persistent.Base;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.Validation;
using DevExpress.ExpressApp.Localization;
using DevExpress.Persistent.Base.General;
namespace XSolution1.Module

    [DefaultClassOptions]   
    
public class Department : BaseObject, IHCategory
    { 
        
private string name; 
        
private Department parent; 
        
private void CheckCircularReferences(Department obj) 
        { Department currentObj 
= obj; while (currentObj != null
        {
            
if (currentObj == this) { throw new UserFriendlyException(ExceptionId.CircularReference);
            } currentObj 
= currentObj.Parent; } } 
        
public Department(Session session) : base(session) { } 
        
public Department(Session session, string name) : this(session) { this.name = name; } 
        [Association(
"DepartmentParent-DepartmentChild")]        
        
public XPCollection<Department> Children 
        {
            
get { return GetCollection<Department>("Children"); }
        } 
        [Persistent, Association(
"DepartmentParent-DepartmentChild")]        
        
public Department Parent 
        { 
            
get { return parent; } 
            
set {
                  
if (!IsLoading) 
                  { 
                      CheckCircularReferences(value);
                  }
                parent 
= value; OnChanged("Parent");
            }
        } 
        
public string Name 
        { 
            
get { return name; }
            
set { name = value; OnChanged("Name"); } 
        } 
        IBindingList ITreeNode.Children 
        {
            
get { return Children as IBindingList; }
        } 
        ITreeNode IHCategory.Parent 
        { 
            
get { return Parent as IHCategory; } 
            
set { Parent = value as Department; }
        }
        ITreeNode ITreeNode.Parent 
        { 
            
get { return Parent as ITreeNode; }
        }
    }
}

 

相关文章:

  • 2021-11-24
  • 2021-07-24
  • 2021-06-01
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-05-19
  • 2022-12-23
  • 2021-07-28
  • 2021-06-26
  • 2021-10-05
  • 2021-05-31
  • 2022-12-23
相关资源
相似解决方案