TreeList应用(三) 收藏

 今天正好有空,昨晚写的程序未带到公司,无法继续写,公司生产管理解决方案及相关流程调整建议已经写完,需等公司领导审批,现在正好写写。

在前在两篇讲到TreeList的绑定问题,接下来讲讲TreeList的操作。

在GridControl中有EmbeddedNavigator控件进行数据的新增,删除等功能,但TreeList中却没有提供这样的功能,好在有一个controlNavigator控件,将此控件的NavigatableControl属性设为对应的TreeList 控件就可以进行相关操作了。

但是也别高兴太早,由于TreeList新建的模式不同于GridControl,所以需要重写NavigatableControl的新增事件。

为NavigatableControl增加ButtonClick事件

private void controlNavigator1_ButtonClick(object sender, DevExpress.XtraEditors.NavigatorButtonClickEventArgs e)
        {
            if (e.Button.ButtonType = DevExpress.XtraEditors.NavigatorButtonType.Append)
            {
                treeList1.AppendNode(new DataRow(), treeList1.FocusedNode);
                e.Handled = true;   //取消默认新增事件
            }
        }

一般来讲需要自定义再增加一个新增控钮,一个用以新增所有节点同一级的节点,另一个用于新增所选节点的子结点。

同时还需留意,使用AppendNode时,需判定后面那个参数是否为空

来自博客园煎蛋的专栏http://blog.csdn.net/stanley_liu/archive/2008/11/12/3281384.aspx

原文地址:https://www.cnblogs.com/JoshuaDreaming/p/1977805.html