/// <summary> /// TreeList 控件Context菜单。 /// </summary> /// <param name="xtraGrid"></param> /// <param name="menuTypes"></param> public TreeListContextMenu(TreeListEx treList, XtraContextMenuType menuTypes) { _TreList = treList; _GridMenu = new System.Windows.Forms.ContextMenu(); CreateMenuItems(menuTypes); }
/// <summary> /// 树型控件绑定处理。 /// </summary> /// <typeparam name="T"></typeparam> /// <param name="trvList"></param> /// <param name="dataList"></param> /// <param name="colPropertys"></param> /// <param name="editCols"></param> /// <param name="treeCfgInfo"></param> /// <param name="allowEdit"></param> public virtual void CreateDataBinding(DevExpress.XtraTreeList.TreeList trvList, object dataSource, Dictionary <string, MB.WinBase.Common.ColumnPropertyInfo> colPropertys, Dictionary <string, MB.WinBase.Common.ColumnEditCfgInfo> editCols, MB.WinBase.Common.TreeListViewCfgInfo treeCfgInfo, bool allowEdit) { if (treeCfgInfo == null) { throw new MB.Util.APPException("绑定TreeListView 控件时,对应 TreeListViewCfgInfo 配置的配置不能为空", MB.Util.APPMessageType.SysErrInfo); } Type entityType = typeof(T); if (entityType.GetProperty(treeCfgInfo.KeyFieldName) == null) { throw new MB.Util.APPException(string.Format("绑定 TreeListView 控件时,实体定义中不包含字段{0}", treeCfgInfo.KeyFieldName), MB.Util.APPMessageType.SysErrInfo); } trvList.KeyFieldName = treeCfgInfo.KeyFieldName; if (entityType.GetProperty(treeCfgInfo.ParentFieldName) == null) { throw new MB.Util.APPException(string.Format("绑定 TreeListView 控件时,实体定义中不包含字段{0}", treeCfgInfo.ParentFieldName), MB.Util.APPMessageType.SysErrInfo); } trvList.ParentFieldName = treeCfgInfo.ParentFieldName; if (entityType.GetProperty(treeCfgInfo.DisplayFieldName) == null) { throw new MB.Util.APPException(string.Format("绑定 TreeListView 控件时,实体定义中不包含字段{0}", treeCfgInfo.DisplayFieldName), MB.Util.APPMessageType.SysErrInfo); } trvList.PreviewFieldName = treeCfgInfo.DisplayFieldName; CreateViewColumns(trvList, colPropertys, editCols, allowEdit); trvList.DataSource = dataSource; TreeListEx treeEx = trvList as TreeListEx; if (treeEx != null) { treeEx.ReSetContextMenu(XtraContextMenuType.SaveGridState | XtraContextMenuType.Export | XtraContextMenuType.SortChildNode); TreeListHelper.RestoreXtraGridState(treeEx); } }