转TreeList(二)

1.TreeList.NodeCellStyle事件

Node的显示(包括窗口的切换导致Node的显示)和状态的改变都会触发该事件。该事件主要用来改变Node的显示样式。

private void treeList1_NodeCellStyle(object sender, DevExpress.XtraTreeList.GetCustomNodeCellStyleEventArgs e)
        {
            if (e.Node.CheckState == CheckState.Unchecked) 
            {
                e.Appearance.Font = new Font(DevExpress.Utils.AppearanceObject.DefaultFont, FontStyle.Strikeout);
                e.Appearance.ForeColor = Color.Gray;
            }
        }

上面的代码是实现的效果是 : CheckState为Unchecked的节点的字带有中划线且背景灰色。

2.TreeList.DoubleClick事件

双击Node时触发,但要注意的是要在TreeList.OptionsBehavior.Editable = false的情况下,双击Node才能触发该事件。

       

private void treeList1_DoubleClick(object sender, EventArgs e)
        {
            TreeListNode clickedNode = this.treeList1.FocusedNode;
            string disPlayText = clickedNode.GetDisplayText("test");  
            MessageBox.Show("You clicked " + disPlayText);
        }

3.TreeList的命中测试特性

private void treeList1_MouseMove(object sender, MouseEventArgs e)
        {
            Point point = treeList1.PointToClient(Cursor.Position);
            TreeListHitInfo hitInfo = treeList1.CalcHitInfo(point);
            switch (hitInfo.HitInfoType) 
            { 
                case HitInfoType.Cell:
                    this.Cursor = Cursors.Hand;
                    break;
                case HitInfoType.NodeCheckBox:
                    this.Cursor = Cursors.PanEast;
                    break;
                default :
                    this.Cursor = Cursors.Default;
                    break;
            }
        }

原文地址:http://www.cnblogs.com/LouisZhu/archive/2010/05/08/1730768.html

原文地址:https://www.cnblogs.com/yulijunzj/p/4413641.html