/// <summary> /// 绑定关系树 /// </summary> /// <param name="treeList"></param> /// <param name="relationTypeList"></param> private void BindRelationTree(DevExpress.XtraTreeList.TreeList treeList, List <MyRelationInfo> relationInfoList) { treeList.OptionsBehavior.Editable = false; treeList.BeginUpdate(); treeList.Nodes.Clear(); foreach (MyRelationInfo item in relationInfoList) { //树的第一级节点,进入递归 if (item.RELATIONINFO_GRADE == 1) { TreeListNode node = treeList.AppendNode(new object[] { item.RELATIONINFO_ID, item.RELATIONINFO_CODE, item.RELATIONINFO_NAME, item.RELATIONINFO_PARENTID, item.RELATIONINFO_IFDETAIL, item.RELATIONINFO_GRADE, item.RELATIONINFO_IFINVALID, item.RELATIONINFO_NOTE, item.RELATIONINFO_CREATETIME, item.RELATIONINFO_LASTMODIFIEDTIME, item.RELATIONINFO_MODIFICATIONTIMES }, null); node.StateImageIndex = 0;//关系的图片 //绑定子关系 LoadRelationTreeNode(treeList, node, item, relationInfoList); } } treeList.EndUpdate(); }
/// <summary> /// 绑定treelist /// </summary> /// <param name="treeList"></param> /// <param name="eventTypeList"></param> private void BindTree(DevExpress.XtraTreeList.TreeList treeList, List <MyEventType> eventTypeList) { treeList.OptionsBehavior.Editable = false; treeList.BeginUpdate(); treeList.Nodes.Clear(); foreach (MyEventType item in eventTypeList) { //树的第一级节点,进入递归 if (item.EVENTTYPE_GRADE == 1) { TreeListNode node = treeList.AppendNode(new object[] { item.EVENTTYPE_ID, item.EVENTTYPE_CODE, item.EVENTTYPE_NAME, item.EVENTTYPE_PARENTID, item.EVENTTYPE_IFDETAIL, item.EVENTTYPE_GRADE, item.EVENTTYPE_IFINVALID, item.EVENTTYPE_NOTE, item.EVENTTYPE_CREATETIME, item.EVENTTYPE_LASTMODIFIEDTIME, item.EVENTTYPE_MODIFICATIONTIMES, "EventType" }, null); node.StateImageIndex = 0;//类型的图片 //绑定子类型 LoadTypeTreeNode(treeList, node, item, eventTypeList); LoadInfoTreeNode(treeList, node, item.EVENTTYPE_EVENTINFO); } } treeList.EndUpdate(); }
private void OnBeforePrint(object sender, System.Drawing.Printing.PrintEventArgs e) { DevExpress.XtraTreeList.TreeList tree = new DevExpress.XtraTreeList.TreeList(); tree.ParentChanged += new EventHandler(tree_ParentChanged); tree.BeginUpdate(); DevExpress.XtraTreeList.Columns.TreeListColumn colName = new DevExpress.XtraTreeList.Columns.TreeListColumn(); colName.Caption = "Name"; colName.FieldName = "Name"; colName.Name = "colName"; colName.Visible = true; colName.VisibleIndex = 0; colName.Width = 45; tree.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { colName }); WinControlContainer wcc = new WinControlContainer(); this.ReportHeader.Controls.Add(wcc); wcc.WinControl = tree; tree.KeyFieldName = "Oid"; tree.ParentFieldName = "Parent!Key"; tree.DataSource = this.DataSource; tree.EndUpdate(); }
private void InitializeTree() { List <MyParameter> para = new List <MyParameter>(); para.Add("@Menu_Id", DbType.String, SysPage.Menu_Id, null); DataTable dt_Sys_WorkSet = BaseService.Open("SystemMenu_Tree", para); List <Sys_Tree> sys_Trees = EntityHelper.GetEntities <Sys_Tree>(dt_Sys_WorkSet); foreach (Sys_Tree sys_Tree in sys_Trees) { Control[] controls = this.Controls.Find(sys_Tree.Tree_Grid, true); if (controls.Length > 0) { if (controls[0].GetType().Equals(typeof(GridControl))) { GridControl grid = (GridControl)controls[0]; DevExpress.XtraTreeList.TreeList tree = new DevExpress.XtraTreeList.TreeList(); tree.BeginUpdate(); tree.ParentFieldName = sys_Tree.Tree_Parent; tree.KeyFieldName = sys_Tree.Tree_Key; //tree.PreviewFieldName tree.CheckBoxFieldName = sys_Tree.Tree_Check; DevExpress.XtraTreeList.Columns.TreeListColumn col = new DevExpress.XtraTreeList.Columns.TreeListColumn(); col.FieldName = sys_Tree.Tree_Display; col.Name = "t_" + sys_Tree.Tree_Display; col.Visible = true; col.VisibleIndex = 1; tree.OptionsBehavior.Editable = false; if (!sys_Tree.Tree_ReadOnly) { tree.DoubleClick += BindTreeEditor; tree.OptionsDragAndDrop.DragNodesMode = DevExpress.XtraTreeList.DragNodesMode.Single; } else { GridView abv = (GridView)grid.MainView; abv.OptionsBehavior.Editable = false; abv.OptionsBehavior.AllowAddRows = DevExpress.Utils.DefaultBoolean.False; abv.OptionsBehavior.AllowDeleteRows = DevExpress.Utils.DefaultBoolean.False; tree.OptionsDragAndDrop.DragNodesMode = DevExpress.XtraTreeList.DragNodesMode.None; } tree.Columns.Add(col); tree.OptionsView.ShowIndicator = false; tree.OptionsView.ShowColumns = false; tree.OptionsView.ShowHorzLines = false; tree.OptionsView.ShowVertLines = false; tree.OptionsView.ShowCheckBoxes = !string.IsNullOrEmpty(sys_Tree.Tree_Check); tree.Name = "tree_" + grid.Name; tree.BorderStyle = BorderStyles.NoBorder; grid.Controls.Add(tree); //tree.PopulateColumns(); tree.BringToFront(); tree.Dock = DockStyle.Fill; tree.GotFocus += Control_GotFocus; grid.DataSourceChanged += BindTreeDataSource; tree.Visible = !sys_Tree.Tree_Hide; tree.EndUpdate(); //切换视图 Control grp = grid.Parent; if (grp.GetType() == typeof(GroupControl)) { //grp.DoubleClick += DoNothing; grp.DoubleClick += delegate { tree.Visible = !tree.Visible; }; } } } } }