private void InitializeTreeList() { this.treeList1.Columns.AddRange( new DevExpress.XtraTreeList.Columns.TreeListColumn[] { this.colID = this.createIDColumn(), this.colName = this.createNameColumn(), this.colPreview = this.createPreviewColumn(), } ); this.treeList1.StateImageList = this.imageCollection1; this.treeList1.GetStateImage += new DevExpress.XtraTreeList.GetStateImageEventHandler(this.treeList1_GetStateImage); this.treeList1.GetSelectImage += new DevExpress.XtraTreeList.GetSelectImageEventHandler(this.treeList1_GetSelectImage); { this.treeList1.PreviewFieldName = this.colPreview.FieldName; this.treeList1.OptionsView.AutoCalcPreviewLineCount = true; this.treeList1.OptionsView.AutoWidth = true; this.treeList1.OptionsView.ShowPreview = false; // this.treeList1.OptionsView.ShowCheckBoxes = true; //this.treeList1.OptionsBehavior.AllowBoundCheckBoxesInVirtualMode = true; //this.treeList1.OptionsBehavior.AllowIndeterminateCheckState = true; this.treeList1.OptionsBehavior.AllowRecursiveNodeChecking = true; this.treeList1.OptionsBehavior.AllowExpandOnDblClick = true; this.treeList1.BeginUnboundLoad(); { this.treeList1.DataSource = new object(); this.treeList1.VirtualTreeGetChildNodes += new VirtualTreeGetChildNodesEventHandler(this.treeList1_VirtualTreeGetChildNodes); this.treeList1.VirtualTreeGetCellValue += new VirtualTreeGetCellValueEventHandler(this.treeList1_VirtualTreeGetCellValue); this.treeList1.VirtualTreeSetCellValue += new VirtualTreeSetCellValueEventHandler(this.treeList1_VirtualTreeSetCellValue); } this.treeList1.EndUnboundLoad(); } this.treeList1.MouseDown += new System.Windows.Forms.MouseEventHandler(this.treeList1_MouseDown); this.treeList1.ToolTipController = DevExpress.Utils.ToolTipController.DefaultController; }
public SelectedCell(int node, int col, DevExpress.XtraTreeList.Nodes.TreeListNode n, DevExpress.XtraTreeList.Columns.TreeListColumn cols) { _id = node; _col = col; _node = n; _cols = cols; }
//TreeList单元格内容改变 private void treeList1_CellValueChanged(object sender, CellValueChangedEventArgs e) { TreeList currentTreeList = sender as TreeList; if (currentTreeList != null) { TreeListNode node = currentTreeList.FocusedNode; DevExpress.XtraTreeList.Columns.TreeListColumn column = currentTreeList.FocusedColumn; string a = treeList1.FocusedNode.GetValue(column.FieldName).ToString(); string name = node.GetDisplayText("NodeCode"); node.SetValue(column.FieldName, "0"); } }
//添加固定列 private void AddFixColumn() { // treeList1.Columns.Add(year + "年", typeof(double)); DevExpress.XtraTreeList.Columns.TreeListColumn column = new DevExpress.XtraTreeList.Columns.TreeListColumn(); column.FieldName = "Title"; column.Caption = "分类名"; column.VisibleIndex = 0; column.Width = 180; this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { column }); column = new DevExpress.XtraTreeList.Columns.TreeListColumn(); column.FieldName = "Sort"; column.VisibleIndex = -1; this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { column }); column = new DevExpress.XtraTreeList.Columns.TreeListColumn(); column.FieldName = "ForecastID"; column.VisibleIndex = -1; this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { column }); column = new DevExpress.XtraTreeList.Columns.TreeListColumn(); column.FieldName = "Forecast"; column.VisibleIndex = -1; this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { column }); column = new DevExpress.XtraTreeList.Columns.TreeListColumn(); column.FieldName = "ID"; column.VisibleIndex = -1; this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { column }); column = new DevExpress.XtraTreeList.Columns.TreeListColumn(); column.FieldName = "ParentID"; column.VisibleIndex = -1; this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { column }); }
private void treeList1_DoubleClick(object sender, EventArgs e) { TreeListNode tree = this.treeList1.FocusedNode; if (tree == null) { return; } string name = tree.GetDisplayText("Customer"); string formname = tree.GetDisplayText("Phone"); TreeListNode node = treeList1.FocusedNode; DevExpress.XtraTreeList.Columns.TreeListColumn column = treeList1.FocusedColumn; if (column.FieldName == "NodeName" && node.GetValue(0).ToString() != "") { } TreeListNode praNode = tree.ParentNode; }
//添加年份后,新增一列 private void AddColumn(int year) { // treeList1.Columns.Add(year + "年", typeof(double)); // TreeListColumn column = treeList1.Columns.Add(); DevExpress.XtraTreeList.Columns.TreeListColumn column = new DevExpress.XtraTreeList.Columns.TreeListColumn(); column.FieldName = "y" + year; column.Tag = year; column.Caption = year + "年"; column.Name = year.ToString(); column.Width = 100; column.OptionsColumn.AllowSort = false; column.VisibleIndex = year;//有两列隐藏列 // column.ColumnEdit = repositoryItemTextEdit1; this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { column }); }
//列表中单元格编辑 private void treeList1_ShowingEditor(object sender, CancelEventArgs e) { TreeList currentTreeList = sender as TreeList; if (currentTreeList != null) { TreeListNode node = currentTreeList.FocusedNode; DevExpress.XtraTreeList.Columns.TreeListColumn column = currentTreeList.FocusedColumn; if (column.FieldName == "NodeName" && node.GetValue(0).ToString() != "") { e.Cancel = true; } else { e.Cancel = false; } string a = treeList1.FocusedNode.GetValue(column.FieldName).ToString(); // MessageBox.Show(a); } }
private void AddMetadaDataValues() { { this.treeList1.RootValue = -1; this.treeList1.ParentFieldName = "ParentId"; this.treeList1.KeyFieldName = "Id"; this.treeList1.PreviewFieldName = "Description"; // TreeView emulation... //this.treeList1.TreeViewColumn = treeList1.Columns[0]; this.treeList1.TreeViewFieldName = "Name"; } this.treeList1.Columns.AddRange( new DevExpress.XtraTreeList.Columns.TreeListColumn[] { this.colParentId = createParentIdColumn(), this.colId = createIdColumn(), this.colName = createNameColumn(), this.colDescription = createDescriptionColumn(), } ); }
private void ConfigTreeList(bool x = true) { if (x) { this.treeList1.Columns.AddRange( new DevExpress.XtraTreeList.Columns.TreeListColumn[] { this.colType = this.createTypeColumn(), this.colName = this.createNameColumn(), this.colDescription = this.createDescriptionColumn() } ); } TreeListColumnCollection columns = this.treeList1.Columns; { this.treeList1.PreviewFieldName = this.colDescription.FieldName; this.treeList1.OptionsView.AutoCalcPreviewLineCount = true; this.treeList1.OptionsView.AutoWidth = true; this.treeList1.OptionsView.ShowPreview = true; this.treeList1.OptionsView.ShowCheckBoxes = true; this.treeList1.OptionsBehavior.AllowBoundCheckBoxesInVirtualMode = true; this.treeList1.OptionsBehavior.AllowIndeterminateCheckState = true; this.treeList1.OptionsBehavior.AllowRecursiveNodeChecking = true; this.treeList1.OptionsBehavior.AllowExpandOnDblClick = true; } this.treeList1.BeginUnboundLoad(); { this.treeList1.DataSource = new object(); //this.treeList1.RefreshDataSource(); } this.treeList1.EndUnboundLoad(); this.ConfigureTreeListUnboundDataHandles(); //{ // this.treeList1.RestoreLayoutFromXml(@"D:\TEMP\SQLite\treeListLayout.xml"); // this.treeList1.ImportFromXml(@"D:\TEMP\SQLite\treeListData.xml"); //} }
private void CreateTreeViewSimple() { DevExpress.XtraTreeList.TreeList treeList1 = new DevExpress.XtraTreeList.TreeList() { Dock = WF.DockStyle.Fill }; DevExpress.XtraTreeList.Columns.TreeListColumn treeListColumn1 = new DevExpress.XtraTreeList.Columns.TreeListColumn(); DevExpress.XtraTreeList.Columns.TreeListColumn treeListColumn2 = new DevExpress.XtraTreeList.Columns.TreeListColumn(); treeList1.Parent = this; this.Controls.Add(treeList1); // Musí být dřív než se začne pracovat s daty!!! _TreeList = treeList1; ((System.ComponentModel.ISupportInitialize)(treeList1)).BeginInit(); this.SuspendLayout(); treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { treeListColumn1, treeListColumn2 }); treeListColumn1.OptionsColumn.AllowEdit = false; treeListColumn1.OptionsColumn.AllowSort = false; treeList1.OptionsView.FocusRectStyle = DrawFocusRectStyle.RowFocus; treeList1.BeginUnboundLoad(); var node0 = treeList1.AppendNode(new object[] { "Node 1", "Popisek" }, -1); var node1 = treeList1.AppendNode(new object[] { "Node 11", "Popisek" }, 0); var node2 = treeList1.AppendNode(new object[] { "Node 2", "Popisek" }, -1); var node3 = treeList1.AppendNode(new object[] { "Node 21", "Popisek" }, 2); var node4 = treeList1.AppendNode(new object[] { "Node 22", "Popisek" }, 2); var node5 = treeList1.AppendNode(new object[] { "Node 3", "Popisek" }, -1); var node6 = treeList1.AppendNode(new object[] { "Node 31", "Popisek" }, 5); // treeList1.SelectImageList = _Images16; // Odkazuje se na node.ImageIndex nebo SelectImageIndex: reprezentuje první ikonu, když prvek je/není Selected treeList1.StateImageList = _Images16; // Odkazuje se na node.StateImageIndex: reprezentuje statickou ikonu u Node node0.CheckState = CheckState.Checked; node0.ImageIndex = -1; // Ikona když node NENÍ Selected, bere se z SelectImageList. Pokud není nastaveno, je zde 0 a bere se první ikona z Listu. node0.SelectImageIndex = 1; // Ikona když node JE Selected, bere se z SelectImageList node0.StateImageIndex = 3; // Trvalá ikona za první ikonou, bere se z StateImageList, nemění se při Selected node0.Expanded = true; node1.ImageIndex = -1; // Ikona když node NENÍ Selected, bere se z SelectImageList. Pokud není nastaveno, je zde 0 a bere se první ikona z Listu. node1.SelectImageIndex = -1; node1.StateImageIndex = 5; node2.StateImageIndex = 5; node2.SelectImageIndex = 13; node3.StateImageIndex = 11; node3.SelectImageIndex = 14; node4.StateImageIndex = 18; node4.SelectImageIndex = 16; treeList1.EndUnboundLoad(); treeList1.OptionsView.AutoWidth = false; treeListColumn1.Caption = "treeListColumn1"; treeListColumn1.FieldName = "treeListColumn1"; treeListColumn1.Name = "treeListColumn1"; treeListColumn1.Visible = true; treeListColumn1.VisibleIndex = 0; treeListColumn1.Width = 122; ((System.ComponentModel.ISupportInitialize)(treeList1)).EndInit(); this.ResumeLayout(false); treeList1.ViewStyle = TreeListViewStyle.TreeView; }
//�����ݺ�����һ�� private void AddColumn(int year) { // treeList1.Columns.Add(year + "��", typeof(double)); // TreeListColumn column = treeList1.Columns.Add(); DevExpress.XtraTreeList.Columns.TreeListColumn column = new DevExpress.XtraTreeList.Columns.TreeListColumn(); column.FieldName = "y" + year; column.Tag = year; column.Caption = year + "��"; column.Name = year.ToString(); column.Width = 100; column.OptionsColumn.AllowSort = false; column.VisibleIndex = year;//������������ // column.ColumnEdit = repositoryItemTextEdit1; this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { column}); }
//��ӹ̶��� private void AddFixColumn() { // treeList1.Columns.Add(year + "��", typeof(double)); DevExpress.XtraTreeList.Columns.TreeListColumn column = new DevExpress.XtraTreeList.Columns.TreeListColumn(); column.FieldName = "Title"; column.Caption = "������"; column.VisibleIndex = 0; column.Width = 180; this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { column}); column = new DevExpress.XtraTreeList.Columns.TreeListColumn(); column.FieldName = "Sort"; column.VisibleIndex = -1; this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { column}); column = new DevExpress.XtraTreeList.Columns.TreeListColumn(); column.FieldName = "ForecastID"; column.VisibleIndex = -1; this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { column}); column = new DevExpress.XtraTreeList.Columns.TreeListColumn(); column.FieldName = "Forecast"; column.VisibleIndex = -1; this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { column}); column = new DevExpress.XtraTreeList.Columns.TreeListColumn(); column.FieldName = "ID"; column.VisibleIndex = -1; this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { column}); column = new DevExpress.XtraTreeList.Columns.TreeListColumn(); column.FieldName = "ParentID"; column.VisibleIndex = -1; this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { column}); }
/// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.treeList1 = new DevExpress.XtraTreeList.TreeList(); this.treeListColumn1 = new DevExpress.XtraTreeList.Columns.TreeListColumn(); this.repositoryItemCheckEdit1 = new DevExpress.XtraEditors.Repository.RepositoryItemCheckEdit(); this.treeListColumn2 = new DevExpress.XtraTreeList.Columns.TreeListColumn(); ((System.ComponentModel.ISupportInitialize)(this.treeList1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.repositoryItemCheckEdit1)).BeginInit(); this.SuspendLayout(); // // treeList1 // this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[] { this.treeListColumn1, this.treeListColumn2 }); this.treeList1.Dock = System.Windows.Forms.DockStyle.Top; this.treeList1.Location = new System.Drawing.Point(0, 0); this.treeList1.Name = "treeList1"; this.treeList1.BeginUnboundLoad(); this.treeList1.AppendNode(new object[] { false, "1" }, -1); this.treeList1.AppendNode(new object[] { false, "2" }, -1); this.treeList1.AppendNode(new object[] { false, "21" }, 1); this.treeList1.AppendNode(new object[] { false, "211" }, 2); this.treeList1.AppendNode(new object[] { false, "212" }, 2); this.treeList1.AppendNode(new object[] { false, "213" }, 2); this.treeList1.AppendNode(new object[] { false, "214" }, 2); this.treeList1.AppendNode(new object[] { false, "22" }, 1); this.treeList1.AppendNode(new object[] { false, "23" }, 1); this.treeList1.AppendNode(new object[] { false, "24" }, 1); this.treeList1.AppendNode(new object[] { false, "3" }, -1); this.treeList1.AppendNode(new object[] { false, "4" }, -1); this.treeList1.AppendNode(new object[] { false, "5" }, -1); this.treeList1.AppendNode(new object[] { false, "6" }, -1); this.treeList1.AppendNode(new object[] { false, "7" }, -1); this.treeList1.AppendNode(new object[] { false, "8" }, -1); this.treeList1.AppendNode(new object[] { false, "9" }, -1); this.treeList1.AppendNode(new object[] { false, "10" }, -1); this.treeList1.EndUnboundLoad(); this.treeList1.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[] { this.repositoryItemCheckEdit1 }); this.treeList1.Size = new System.Drawing.Size(592, 400); this.treeList1.TabIndex = 0; // // treeListColumn1 // this.treeListColumn1.Caption = "Column1"; this.treeListColumn1.ColumnEdit = this.repositoryItemCheckEdit1; this.treeListColumn1.FieldName = "treeListColumn1"; this.treeListColumn1.MinWidth = 56; this.treeListColumn1.Name = "treeListColumn1"; this.treeListColumn1.Visible = true; this.treeListColumn1.VisibleIndex = 0; // // repositoryItemCheckEdit1 // this.repositoryItemCheckEdit1.AutoHeight = false; this.repositoryItemCheckEdit1.Name = "repositoryItemCheckEdit1"; this.repositoryItemCheckEdit1.CheckedChanged += new System.EventHandler(this.repositoryItemCheckEdit1_CheckedChanged); // // treeListColumn2 // this.treeListColumn2.Caption = "Column2"; this.treeListColumn2.FieldName = "treeListColumn2"; this.treeListColumn2.Name = "treeListColumn2"; this.treeListColumn2.Visible = true; this.treeListColumn2.VisibleIndex = 1; // // Form1 // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(592, 527); this.Controls.Add(this.treeList1); this.Name = "Form1"; this.Text = "How to change the field value of all child nodes of a certain node"; ((System.ComponentModel.ISupportInitialize)(this.treeList1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.repositoryItemCheckEdit1)).EndInit(); this.ResumeLayout(false); }
protected override void RaiseColumnChanged(DevExpress.XtraTreeList.Columns.TreeListColumn column) { base.RaiseColumnChanged(column); RaiseColumnsLayout(); //RaiseColumnsColor(column); }