void treeList1_MouseClick(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Right && ModifierKeys == Keys.None && treeList1.State == TreeListState.Regular) { Point pt = this.PointToClient(MousePosition); TreeListHitInfo info = treeList1.CalcHitInfo(pt); if (info.HitInfoType == HitInfoType.Cell || info.HitInfoType == HitInfoType.StateImage) { treeList1.FocusedNode = info.Node; ABCCommonTreeListNode obj = (ABCCommonTreeListNode)treeList1.GetDataRecordByNode(treeList1.FocusedNode); if (obj == null || (DataStructInfo)obj.InnerData == null) { return; } DataStructInfo data = (DataStructInfo)obj.InnerData; if (DataStructureProvider.IsForeignKey(data.TableName, data.FieldName)) { ContextMenu.ShowPopup(MousePosition); } } } else if (e.Button == MouseButtons.Left && ModifierKeys == Keys.None && treeList1.State == TreeListState.NodePressed) { ABCCommonTreeListNode obj = (ABCCommonTreeListNode)treeList1.GetDataRecordByNode(treeList1.FocusedNode); if (obj == null || (DataStructInfo)obj.InnerData == null) { return; } (obj.InnerData as DataStructInfo).Selected = !(obj.InnerData as DataStructInfo).Selected; if ((obj.InnerData as DataStructInfo).Selected) { foreach (DataStructInfo data in lstData) { if (data != (obj.InnerData as DataStructInfo) && data.TotalFieldName != (obj.InnerData as DataStructInfo).TotalFieldName) { data.Selected = false; } } } treeList1.RefreshDataSource(); } }
public void ExploreFKNode(ABCCommonTreeListNode obj) { DataStructInfo data = (DataStructInfo)obj.InnerData; if (DataStructureProvider.IsForeignKey(data.TableName, data.FieldName)) { String strPKTableName = DataStructureProvider.GetTableNameOfForeignKey(data.TableName, data.FieldName); if (DataStructureProvider.DataTablesList.ContainsKey(strPKTableName) == false) { return; } foreach (String strFieldName in DataStructureProvider.DataTablesList[strPKTableName].ColumnsList.Keys) { DataStructInfo dataInfo = new DataStructInfo(strPKTableName, strFieldName); dataInfo.TotalFieldName = data.TotalFieldName + ":" + strFieldName; lstData.Add(dataInfo); new ABCCommonTreeListNode(obj, dataInfo); } } }
public void Initialize( ) { treeList1.OptionsBehavior.ShowEditorOnMouseUp = false; treeList1.OptionsBehavior.CloseEditorOnLostFocus = true; treeList1.OptionsBehavior.ImmediateEditor = false; treeList1.OptionsSelection.UseIndicatorForSelection = false; treeList1.OptionsView.ShowColumns = true; treeList1.OptionsView.ShowVertLines = false; treeList1.OptionsView.ShowHorzLines = false; treeList1.OptionsView.ShowFocusedFrame = false; treeList1.OptionsBehavior.DragNodes = false; #region Columns DevExpress.XtraTreeList.Columns.TreeListColumn colField = new DevExpress.XtraTreeList.Columns.TreeListColumn(); colField.Caption = "Field"; colField.FieldName = "FieldName"; colField.Visible = true; colField.VisibleIndex = 0; colField.OptionsColumn.AllowEdit = false; DevExpress.XtraTreeList.Columns.TreeListColumn colCheck = new DevExpress.XtraTreeList.Columns.TreeListColumn(); colCheck.Caption = "Select"; colCheck.FieldName = "Selected"; colCheck.Visible = true; colCheck.VisibleIndex = 0; colCheck.OptionsColumn.AllowEdit = true; colCheck.Width = 20; repoCheck = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit(); colCheck.ColumnEdit = repoCheck; treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { colCheck, colField }); #endregion ABCCommonTreeListNode root = new ABCCommonTreeListNode(null, null); foreach (String strFieldName in DataStructureProvider.DataTablesList[this.TableName].ColumnsList.Keys) { DataStructInfo dataInfo = new DataStructInfo(TableName, strFieldName); new ABCCommonTreeListNode(root, dataInfo); lstData.Add(dataInfo); } treeList1.DataSource = root; treeList1.RefreshDataSource(); treeList1.Refresh(); if (treeList1.Nodes.Count > 0) { treeList1.FocusedNode = treeList1.Nodes[0]; } InitOldResult(root); treeList1.ExpandAll(); colCheck.Width = 20; treeList1.MouseClick += new MouseEventHandler(treeList1_MouseClick); treeList1.CustomDrawNodeCell += new CustomDrawNodeCellEventHandler(treeList1_CustomDrawNodeCell); repoCheck.EditValueChanged += new EventHandler(repoCheck_EditValueChanged); InitPopupMenu(); }