DEVEXPRESS-----TREELIST 的 增加、删除节点

转载 2006年05月30日 15:49:00

  注意采用了两个treeListColumn,一个用来展示名称,一个用来展示编码.这样的好处在于作品名维护的时候,可以调用编码,而不需要重新匹配对比了.下面是完整的代码.

using System;
using System.Drawing;
using System. Collections;
using System.ComponentModel;
using System.Windows.Forms;

namespace WindowsApplication1
{
    
/**//// <summary>
    
/// typemanage 的摘要说明。
    
/// </summary>
    public class typemanage : System.Windows.Forms.Form
    
{
        
private DevExpress.XtraEditors.TextEdit textEdit1;
        
private DevExpress.XtraTreeList.TreeList treeList1;
        
private DevExpress.XtraTreeList.Columns.TreeListColumn treeListColumn1;
        
private DevExpress.XtraEditors.Repository.RepositoryItemTextEdit repositoryItemTextEdit1;
        
private DevExpress.XtraEditors.SimpleButton simpleButton1;
        
private DevExpress.XtraEditors.SimpleButton simpleButton2;
        
private DevExpress.XtraEditors.SimpleButton simpleButton3;
        
private System.Windows.Forms.Label label1;
        
int nodeid=0;
        DevExpress.XtraTreeList.Nodes.TreeListNode deletenode;
        
private DevExpress.XtraTreeList.Columns.TreeListColumn treeListColumn2;
        
private DevExpress.XtraEditors.Repository.RepositoryItemTextEdit repositoryItemTextEdit2;
        
private System.Windows.Forms.Label label2;
        
private DevExpress.XtraEditors.TextEdit textEdit2;
        
/**//// <summary>
        
/// 必需的设计器变量。
        
/// </summary>
        private System.ComponentModel.Container components = null;

        
public typemanage()
        
{
            
//
            // Windows 
窗体设计器支持所必需的
            //
            InitializeComponent();

            
//
            // TODO: 
 InitializeComponent 调用后添加任何构造函数代码
            //
        }

        
/**//// <summary>
        
/// 清理所有正在使用的资源。
        
/// </summary>
        protected override void Dispose( bool disposing )
        
{
            
if( disposing )
            
{
                
if(components != null)
                
{
                    components.Dispose();
                }
            }
            
base.Dispose( disposing );
        }

        
Windows 窗体设计器生成的代码#region Windows 窗体设计器生成的代码
        
/**//// <summary>
        
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
        
/// 此方法的内容。
        
/// </summary>
        private void InitializeComponent()
        
{
            
this.textEdit1 = new DevExpress.XtraEditors.TextEdit();
            
this.treeList1 = new DevExpress.XtraTreeList.TreeList();
            
this.treeListColumn1 = new DevExpress.XtraTreeList.Columns.TreeListColumn();
            
this.repositoryItemTextEdit1 = new DevExpress.XtraEditors.Repository.RepositoryItemTextEdit();
            
this.simpleButton1 = new DevExpress.XtraEditors.SimpleButton();
            
this.simpleButton2 = new DevExpress.XtraEditors.SimpleButton();
            
this.simpleButton3 = new DevExpress.XtraEditors.SimpleButton();
            
this.label1 = new System.Windows.Forms.Label();
            
this.treeListColumn2 = new DevExpress.XtraTreeList.Columns.TreeListColumn();
            
this.repositoryItemTextEdit2 = new DevExpress.XtraEditors.Repository.RepositoryItemTextEdit();
            
this.label2 = new System.Windows.Forms.Label();
            
this.textEdit2 = new DevExpress.XtraEditors.TextEdit();
            ((System.ComponentModel.ISupportInitialize)(
this.textEdit1.Properties)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(
this.treeList1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(
this.repositoryItemTextEdit1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(
this.repositoryItemTextEdit2)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(
this.textEdit2.Properties)).BeginInit();
            
this.SuspendLayout();
            
// 
            // textEdit1
            // 
            this.textEdit1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            
this.textEdit1.EditValue = "新增1";
            
this.textEdit1.Location = new System.Drawing.Point(88, 248);
            
this.textEdit1.Name = "textEdit1";
            
this.textEdit1.Size = new System.Drawing.Size(128, 21);
            
this.textEdit1.TabIndex = 12;
            
// 
            // treeList1
            // 
            this.treeList1.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom) 
                | System.Windows.Forms.AnchorStyles.Right)));
            
this.treeList1.Columns.AddRange(new DevExpress.XtraTreeList.Columns.TreeListColumn[]  {
                                                                                                     
this.treeListColumn1,
                                                                                                     
this.treeListColumn2});
            
this.treeList1.Location = new System.Drawing.Point(224, 16);
            
this.treeList1.Name = "treeList1";
            
this.treeList1.BeginUnboundLoad();
            
this.treeList1.AppendNode(new object[]  {
                                                       "
型材",
                                                       "01"}, -1);
            
this.treeList1.AppendNode(new object[]  {
                                                       "
门窗五金",
                                                       "02"}, -1);
            
this.treeList1.AppendNode(new object[]  {
                                                       "
辅料",
                                                       "03"}, -1);
            
this.treeList1.AppendNode(new object[]  {
                                                       "
中空玻璃用料",
                                                       "04"}, -1);
            
this.treeList1.EndUnboundLoad();
            
this.treeList1.RepositoryItems.AddRange(new DevExpress.XtraEditors.Repository.RepositoryItem[]  {
                                                                                                               
this.repositoryItemTextEdit1,
                                                                                                               
this.repositoryItemTextEdit2});
            
this.treeList1.Size = new System.Drawing.Size(264, 264);
            
this.treeList1.Styles.AddReplace("Preview", new DevExpress.Utils.ViewStyle("Preview", "TreeList", new System.Drawing.Font("Tahoma", 10F), "", DevExpress.Utils.StyleOptions.StyleEnabled, truetruefalse, DevExpress.Utils.HorzAlignment.Near, DevExpress.Utils.VertAlignment.Center, null, System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255))), System.Drawing.Color.FromArgb(((System.Byte)(10)), ((System.Byte)(36)), ((System.Byte)(106)))));
            
this.treeList1.Styles.AddReplace("FooterPanel", new DevExpress.Utils.ViewStyle("FooterPanel", "TreeList", new System.Drawing.Font("Tahoma", 10F), "", DevExpress.Utils.StyleOptions.StyleEnabled, truefalsefalse, DevExpress.Utils.HorzAlignment.Far, DevExpress.Utils.VertAlignment.Center, null, System.Drawing.Color.FromArgb(((System.Byte)(212)), ((System.Byte)(208)), ((System.Byte)(200))), System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(0)))));
            
this.treeList1.Styles.AddReplace("GroupButton", new DevExpress.Utils.ViewStyle("GroupButton", "TreeList", new System.Drawing.Font("Tahoma", 10F), "", DevExpress.Utils.StyleOptions.StyleEnabled, truefalsefalse, DevExpress.Utils.HorzAlignment.Default, DevExpress.Utils.VertAlignment.Center, null, System.Drawing.Color.FromArgb(((System.Byte)(252)), ((System.Byte)(248)), ((System.Byte)(240))), System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(0)))));
            
this.treeList1.Styles.AddReplace("EvenRow", new DevExpress.Utils.ViewStyle("EvenRow", "TreeList", new System.Drawing.Font("Tahoma", 10F), "", DevExpress.Utils.StyleOptions.StyleEnabled, truefalsefalse, DevExpress.Utils.HorzAlignment.Default, DevExpress.Utils.VertAlignment.Center, null, System.Drawing.Color.FromArgb(((System.Byte)(212)), ((System.Byte)(208)), ((System.Byte)(200))), System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(0)))));
            
this.treeList1.Styles.AddReplace("TreeLine", new DevExpress.Utils.ViewStyle("TreeLine", "TreeList", new System.Drawing.Font("Microsoft Sans Serif", 8F), "", DevExpress.Utils.StyleOptions.StyleEnabled, truefalsefalse, DevExpress.Utils.HorzAlignment.Default, DevExpress.Utils.VertAlignment.Center, null, System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255))), System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(128)))));
            
this.treeList1.Styles.AddReplace("PressedColumn", new DevExpress.Utils.ViewStyle("PressedColumn", "TreeList", new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold), "HeaderPanel", ((DevExpress.Utils.StyleOptions)(((DevExpress.Utils.StyleOptions.StyleEnabled | DevExpress.Utils.StyleOptions.UseBackColor) 
                | DevExpress.Utils.StyleOptions.UseForeColor))), 
truefalsefalse, DevExpress.Utils.HorzAlignment.Near, DevExpress.Utils.VertAlignment.Center, null, System.Drawing.Color.FromArgb(((System.Byte)(10)), ((System.Byte)(36)), ((System.Byte)(106))), System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255)))));
            
this.treeList1.Styles.AddReplace("HideSelectionRow", new DevExpress.Utils.ViewStyle("HideSelectionRow", "TreeList", new System.Drawing.Font("Tahoma", 10F), "", ((DevExpress.Utils.StyleOptions)((((((DevExpress.Utils.StyleOptions.StyleEnabled | DevExpress.Utils.StyleOptions.UseBackColor) 
                | DevExpress.Utils.StyleOptions.UseDrawFocusRect) 
                | DevExpress.Utils.StyleOptions.UseFont) 
                | DevExpress.Utils.StyleOptions.UseForeColor) 
                | DevExpress.Utils.StyleOptions.UseImage))), 
truefalsefalse, DevExpress.Utils.HorzAlignment.Default, DevExpress.Utils.VertAlignment.Center, null, System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(128))), System.Drawing.Color.FromArgb(((System.Byte)(212)), ((System.Byte)(208)), ((System.Byte)(200)))));
            
this.treeList1.Styles.AddReplace("GroupFooter", new DevExpress.Utils.ViewStyle("GroupFooter", "TreeList", new System.Drawing.Font("Tahoma", 8F), "", DevExpress.Utils.StyleOptions.StyleEnabled, truefalsefalse, DevExpress.Utils.HorzAlignment.Far, DevExpress.Utils.VertAlignment.Center, null, System.Drawing.Color.FromArgb(((System.Byte)(222)), ((System.Byte)(218)), ((System.Byte)(210))), System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(0)))));
            
this.treeList1.Styles.AddReplace("HorzLine", new DevExpress.Utils.ViewStyle("HorzLine", "TreeList", new System.Drawing.Font("Tahoma", 10F), "", DevExpress.Utils.StyleOptions.StyleEnabled, truefalsefalse, DevExpress.Utils.HorzAlignment.Default, DevExpress.Utils.VertAlignment.Center, null, System.Drawing.Color.FromArgb(((System.Byte)(212)), ((System.Byte)(208)), ((System.Byte)(200))), System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(128)))));
            
this.treeList1.Styles.AddReplace("HeaderPanel", new DevExpress.Utils.ViewStyle("HeaderPanel", "TreeList", new System.Drawing.Font("Tahoma", 10F, System.Drawing.FontStyle.Bold), "", DevExpress.Utils.StyleOptions.StyleEnabled, truefalsefalse, DevExpress.Utils.HorzAlignment.Near, DevExpress.Utils.VertAlignment.Center, null, System.Drawing.Color.FromArgb(((System.Byte)(212)), ((System.Byte)(208)), ((System.Byte)(200))), System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(0)))));
            
this.treeList1.Styles.AddReplace("Empty", new DevExpress.Utils.ViewStyle("Empty", "TreeList", new System.Drawing.Font("Microsoft Sans Serif", 8F), "", DevExpress.Utils.StyleOptions.StyleEnabled, truefalsefalse, DevExpress.Utils.HorzAlignment.Default, DevExpress.Utils.VertAlignment.Center, null, System.Drawing.Color.FromArgb(((System.Byte)(232)), ((System.Byte)(228)), ((System.Byte)(220))), System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255)))));
            
this.treeList1.Styles.AddReplace("VertLine", new DevExpress.Utils.ViewStyle("VertLine", "TreeList", new System.Drawing.Font("Tahoma", 10F), "", DevExpress.Utils.StyleOptions.StyleEnabled, truefalsefalse, DevExpress.Utils.HorzAlignment.Near, DevExpress.Utils.VertAlignment.Center, null, System.Drawing.Color.FromArgb(((System.Byte)(212)), ((System.Byte)(208)), ((System.Byte)(200))), System.Drawing.Color.FromArgb(((System.Byte)(128)), ((System.Byte)(128)), ((System.Byte)(128)))));
            
this.treeList1.Styles.AddReplace("FocusedCell", new DevExpress.Utils.ViewStyle("FocusedCell", "TreeList", new System.Drawing.Font("Tahoma", 10F), "", ((DevExpress.Utils.StyleOptions)((((((DevExpress.Utils.StyleOptions.StyleEnabled | DevExpress.Utils.StyleOptions.UseBackColor) 
                | DevExpress.Utils.StyleOptions.UseDrawFocusRect) 
                | DevExpress.Utils.StyleOptions.UseFont) 
                | DevExpress.Utils.StyleOptions.UseForeColor) 
                | DevExpress.Utils.StyleOptions.UseImage))), 
truefalsefalse, DevExpress.Utils.HorzAlignment.Default, DevExpress.Utils.VertAlignment.Center, null, System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(225))), System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(0)))));
            
this.treeList1.Styles.AddReplace("OddRow", new DevExpress.Utils.ViewStyle("OddRow", "TreeList", new System.Drawing.Font("Tahoma", 10F), "", DevExpress.Utils.StyleOptions.StyleEnabled, truefalsefalse, DevExpress.Utils.HorzAlignment.Default, DevExpress.Utils.VertAlignment.Center, null, System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255))), System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(0)))));
            
this.treeList1.Styles.AddReplace("SelectedRow", new DevExpress.Utils.ViewStyle("SelectedRow", "TreeList", new System.Drawing.Font("Tahoma", 10F), "", ((DevExpress.Utils.StyleOptions)((((((DevExpress.Utils.StyleOptions.StyleEnabled | DevExpress.Utils.StyleOptions.UseBackColor) 
                | DevExpress.Utils.StyleOptions.UseDrawFocusRect) 
                | DevExpress.Utils.StyleOptions.UseFont) 
                | DevExpress.Utils.StyleOptions.UseForeColor) 
                | DevExpress.Utils.StyleOptions.UseImage))), 
truefalsefalse, DevExpress.Utils.HorzAlignment.Default, DevExpress.Utils.VertAlignment.Center, null, System.Drawing.Color.FromArgb(((System.Byte)(20)), ((System.Byte)(46)), ((System.Byte)(116))), System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255)))));
            
this.treeList1.Styles.AddReplace("FocusedRow", new DevExpress.Utils.ViewStyle("FocusedRow", "TreeList", new System.Drawing.Font("Tahoma", 10F), "", ((DevExpress.Utils.StyleOptions)((((((DevExpress.Utils.StyleOptions.StyleEnabled | DevExpress.Utils.StyleOptions.UseBackColor) 
                | DevExpress.Utils.StyleOptions.UseDrawFocusRect) 
                | DevExpress.Utils.StyleOptions.UseFont) 
                | DevExpress.Utils.StyleOptions.UseForeColor) 
                | DevExpress.Utils.StyleOptions.UseImage))), 
truefalsefalse, DevExpress.Utils.HorzAlignment.Default, DevExpress.Utils.VertAlignment.Center, null, System.Drawing.Color.FromArgb(((System.Byte)(10)), ((System.Byte)(36)), ((System.Byte)(106))), System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255)))));
            
this.treeList1.Styles.AddReplace("Row", new DevExpress.Utils.ViewStyle("Row", "TreeList", new System.Drawing.Font("Tahoma", 10F), "", DevExpress.Utils.StyleOptions.StyleEnabled, truefalsefalse, DevExpress.Utils.HorzAlignment.Default, DevExpress.Utils.VertAlignment.Center, null, System.Drawing.Color.FromArgb(((System.Byte)(255)), ((System.Byte)(255)), ((System.Byte)(255))), System.Drawing.Color.FromArgb(((System.Byte)(0)), ((System.Byte)(0)), ((System.Byte)(0)))));
            
this.treeList1.TabIndex = 23;
            
this.treeList1.Text = "类型维护";
            
this.treeList1.FocusedNodeChanged += new DevExpress.XtraTreeList.FocusedNodeChangedEventHandler(this.treeList1_FocusedNodeChanged);
            
this.treeList1.AfterFocusNode += new DevExpress.XtraTreeList.NodeEventHandler(this.treeList1_AfterFocusNode);
            
// 
            // treeListColumn1
            // 
            this.treeListColumn1.Caption = "类型维护----绿城铝业";
            
this.treeListColumn1.ColumnEdit = this.repositoryItemTextEdit1;
            
this.treeListColumn1.FieldName = "类型维护----绿城铝业";
            
this.treeListColumn1.Name = "treeListColumn1";
            
this.treeListColumn1.VisibleIndex = 0;
            
// 
            // repositoryItemTextEdit1
            // 
            this.repositoryItemTextEdit1.AutoHeight = false;
            
this.repositoryItemTextEdit1.Name = "repositoryItemTextEdit1";
            
// 
            // simpleButton1
            // 
            this.simpleButton1.ButtonStyle = DevExpress.XtraEditors.Controls.BorderStyles.Office2003;
            
this.simpleButton1.Location = new System.Drawing.Point(40, 24);
            
this.simpleButton1.Name = "simpleButton1";
            
this.simpleButton1.TabIndex = 27;
            
this.simpleButton1.Text = " 新增根";
            
this.simpleButton1.Click += new System.EventHandler(this.simpleButton1_Click);
            
// 
            // simpleButton2
            // 
            this.simpleButton2.ButtonStyle = DevExpress.XtraEditors.Controls.BorderStyles.Office2003;
            
this.simpleButton2.Location = new System.Drawing.Point(40, 128);
            
this.simpleButton2.Name = "simpleButton2";
            
this.simpleButton2.TabIndex = 28;
            
this.simpleButton2.Text = "删除节点";
            
this.simpleButton2.Click += new System.EventHandler(this.simpleButton2_Click);
            
// 
            // simpleButton3
            // 
            this.simpleButton3.ButtonStyle = DevExpress.XtraEditors.Controls.BorderStyles.Office2003;
            
this.simpleButton3.Location = new System.Drawing.Point(40, 80);
            
this.simpleButton3.Name = "simpleButton3";
            
this.simpleButton3.TabIndex = 30;
            
this.simpleButton3.Text = " 新增子极";
            
this.simpleButton3.Click += new System.EventHandler(this.simpleButton3_Click);
            
// 
            // label1
            // 
            this.label1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            
this.label1.Location = new System.Drawing.Point(8, 256);
            
this.label1.Name = "label1";
            
this.label1.Size = new System.Drawing.Size(80, 16);
            
this.label1.TabIndex = 31;
            
this.label1.Text = "新增节点名称";
            
// 
            // treeListColumn2
            // 
            this.treeListColumn2.Caption = "对应编码";
            
this.treeListColumn2.ColumnEdit = this.repositoryItemTextEdit2;
            
this.treeListColumn2.FieldName = "treeListColumn2";
            
this.treeListColumn2.Name = "treeListColumn2";
            
this.treeListColumn2.VisibleIndex = 1;
            
// 
            // repositoryItemTextEdit2
            // 
            this.repositoryItemTextEdit2.AutoHeight = false;
            
this.repositoryItemTextEdit2.Name = "repositoryItemTextEdit2";
            
// 
            // label2
            // 
            this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            
this.label2.Location = new System.Drawing.Point(8, 288);
            
this.label2.Name = "label2";
            
this.label2.Size = new System.Drawing.Size(80, 16);
            
this.label2.TabIndex = 33;
            
this.label2.Text = "节点对应代码";
            
// 
            // textEdit2
            // 
            this.textEdit2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
            
this.textEdit2.EditValue = "05";
            
this.textEdit2.Location = new System.Drawing.Point(88, 280);
            
this.textEdit2.Name = "textEdit2";
            
this.textEdit2.Size = new System.Drawing.Size(128, 21);
            
this.textEdit2.TabIndex = 32;
            
// 
            // typemanage
            // 
            this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
            
this.ClientSize = new System.Drawing.Size(496, 333);
            
this.Controls.Add(this.label2);
            
this.Controls.Add(this.textEdit2);
            
this.Controls.Add(this.label1);
            
this.Controls.Add(this.simpleButton3);
            
this.Controls.Add(this.simpleButton2);
            
this.Controls.Add(this.simpleButton1);
            
this.Controls.Add(this.treeList1);
            
this.Controls.Add(this.textEdit1);
            
this.Name = "typemanage";
            
this.Text = "类型管理";
            ((System.ComponentModel.ISupportInitialize)(
this.textEdit1.Properties)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(
this.treeList1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(
this.repositoryItemTextEdit1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(
this.repositoryItemTextEdit2)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(
this.textEdit2.Properties)).EndInit();
            
this.ResumeLayout(false);

        }
        
#endregion

        
private void simpleButton1_Click(object sender, System.EventArgs e)
        
{
            
if(textEdit1.Text.Trim()==""||textEdit2.Text.Trim()=="")
            
{
                MessageBox.Show("
请输入对应名称及编码!","错误",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                
return;
            }
            
this.treeList1.AppendNode(new object[]  {this.textEdit1.Text,textEdit2.Text},-1);

        
//            newnode.
        //            this.treeList1.Nodes[0].Nodes.Add(newnode);
       }

        
private void treeList1_FocusedNodeChanged(object sender, DevExpress.XtraTreeList.FocusedNodeChangedEventArgs e)
        
{
            MessageBox.Show(e.Node.Level.ToString());
            MessageBox.Show(e.Node.Id.ToString());
            MessageBox.Show(e.Node.GetDisplayText(0));
        }

        
private void treeList1_AfterFocusNode(object sender, DevExpress.XtraTreeList.NodeEventArgs e)
        
{
            nodeid=e.Node.Id;
            deletenode=e.Node;
        }

        
private void simpleButton3_Click(object sender, System.EventArgs e)
        
{
            
if(textEdit1.Text.Trim()==""||textEdit2.Text.Trim()=="")
            
{
                MessageBox.Show("
请输入对应名称及编码!","错误",MessageBoxButtons.OK,MessageBoxIcon.Warning);
                
return;
            }
            
this.treeList1.AppendNode(new object[]  {this.textEdit1.Text,textEdit2.Text},nodeid);
        }

        
private void simpleButton2_Click(object sender, System.EventArgs e)
        
{
//            MessageBox.Show(nodeid.ToString());
            this.treeList1.DeleteNode(deletenode);
        }
    }
}

TreeList 的 增加、删除节点-----DevExpress

 注意采用了两个treeListColumn,一个用来展示名称,一个用来展示编码.这样的好处在于作品名维护的时候,可以调用编码,而不需要重新匹配对比了.下面是完整的代码. using System; ...
  • yudehui
  • yudehui
  • 2011年02月13日 22:31
  • 13662

C# DEV,treelist,实现分层及TreeList常用用法

dev treelist实现分层及treelist常用方法
  • chensi16114
  • chensi16114
  • 2016年07月28日 11:32
  • 2372

DevExpress中TreeList的一个节点改变父节点也要改变的实例

最近需要做一个功能:在treelist上进行操作,一旦某个列的值进行了改变,那么它的父节点的值也需要跟着改变,同时要将其改变的值保存到数据库。       思路是先得到值改变的那个节点,并循环找到父...
  • wangjinyang_123
  • wangjinyang_123
  • 2014年12月09日 19:34
  • 1378

dev treelist 常用用法小结

要求如下: 1:选择父节点后,子节点全部打钩; 2:选择子节点而不选择父节点,则从当前节点的父节点一直到根节点check框都是半选状态。 3:当子节点均未勾选时,设置父节点状态为:未选中状态 具体实现...
  • xunzaosiyecao
  • xunzaosiyecao
  • 2015年05月18日 12:03
  • 3063

DevExpress使用经验分享:Treelist拖拽节点

本篇要实现的目标,简单来说就是把一个DevExpress treelist的节点用鼠标拖到另外的节点(自身或其他的listview)上,如下图: (图一) (图二) (图三) 首先,在窗口中拉...
  • BTfan123
  • BTfan123
  • 2014年06月20日 11:15
  • 1138

TreeList父子节点的选择

/// /// 选择某一节点时,该节点的子节点全部选择 取消某一节点时,该节点的子节点全部取消选择 /// private void SetCheckedChildNodes(TreeListN...
  • u011065605
  • u011065605
  • 2015年03月19日 12:32
  • 364

treeList获取被勾选的树值

DevExpress的TreeList要想在节点前面显示复选框,得修改属性OptionsView->ShowCheckBoxes=True #region 获取被勾选的树值 ///...
  • GoodChangYong
  • GoodChangYong
  • 2017年04月02日 13:59
  • 502

Dev控件 TreeList的使用,绑定多级树以及多选框的三种状态

Dev控件TreeList
  • qlshuang
  • qlshuang
  • 2015年07月17日 16:52
  • 1661

C# DEV,treelist,实现分层及TreeList常用用法

dev treelist实现分层及treelist常用方法
  • chensi16114
  • chensi16114
  • 2016年07月28日 11:32
  • 2372

DevExpress控件-TreeList内置过滤功能实现(图文)

效果: 实现代码如下: /// /// 窗体加载 /// /// /// private void FrmM...
  • qq395537505
  • qq395537505
  • 2016年05月04日 15:07
  • 1458
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:DEVEXPRESS-----TREELIST 的 增加、删除节点
举报原因:
原因补充:

(最多只允许输入30个字)