using DevExpress.XtraTreeList; using DevExpress.XtraTreeList.Columns; using ProjectBase.Data.BaseDAL; using SIMDP.BLL; using SIMDP.Model; using System; using System.Collections.Generic; using System.Drawing; using System.Windows.Forms; namespace SIMDP.View { public partial class FormAuthoryRight : DevExpress.XtraEditors.XtraForm { //BlAuthoryRight bl = new BlAuthoryRight(); private Dictionary columnNameAlias = new Dictionary();//Treelist中字段别名字典集合 public FormAuthoryRight() { InitializeComponent(); } private void FormAuthoryRight_Load(object sender, EventArgs e) { InitTreeList(); } private void InitTreeList() { #region 添加别名解析 this.treeListRight.Columns.Clear(); columnNameAlias.Clear(); //columnNameAlias.Add("RightId", "权限编码"); columnNameAlias.Add("RightName", "权限名称"); columnNameAlias.Add("RightDescription", "权限描述"); foreach (var item in columnNameAlias) { TreeListColumn col = new TreeListColumn(); col.Caption = item.Value; col.FieldName = item.Key; col.Visible = true; this.treeListRight.Columns.Add(col); } this.treeListRight.KeyFieldName = "RightId"; this.treeListRight.ParentFieldName = "ParentRightId"; this.treeListRight.LookAndFeel.UseDefaultLookAndFeel = false; // 设置“+” ,“-” this.treeListRight.LookAndFeel.UseWindowsXPTheme = true; #endregion List rightList = new List(); rightList = BLLFactory.Instance.GetAll(); this.treeListRight.DataSource = rightList; this.treeListRight.RefreshDataSource(); } /// /// 添加列序号 /// /// /// private void treeListRight_CustomDrawNodeIndicator(object sender, DevExpress.XtraTreeList.CustomDrawNodeIndicatorEventArgs e) { DevExpress.XtraTreeList.TreeList tmpTree = sender as DevExpress.XtraTreeList.TreeList; DevExpress.Utils.Drawing.IndicatorObjectInfoArgs args = e.ObjectArgs as DevExpress.Utils.Drawing.IndicatorObjectInfoArgs; if (args != null) { int rowNum = tmpTree.GetVisibleIndexByNode(e.Node) + 1; this.treeListRight.IndicatorWidth = 30; args.DisplayText = rowNum.ToString(); } } private void menu_Edit_Click(object sender, EventArgs e) { } private void menu_Refresh_Click(object sender, EventArgs e) { InitTreeList(); } } }