如何让DevExpress TreeList的每个结点高亮显示?

原文地址:http://www.devexpresscn.com/devResources/page-18-78.html

效果如下:

代码如下:

复制代码
private void treeList1_CustomDrawNodeCell(object sender, DevExpress.XtraTreeList.CustomDrawNodeCellEventArgs e)

       {

            TreeList node = sender as TreeList;

            if(e.Node == node.FocusedNode)

            {

                e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);

                Rectangle r = new Rectangle(e.EditViewInfo.ContentRect.Left,
                                           e.EditViewInfo.ContentRect.Top,
                                            Convert.ToInt32(e.Graphics.MeasureString(e.CellText,treeList1.Font).Width + 1),
                                            Convert.ToInt32(e.Graphics.MeasureString(e.CellText,treeList1.Font).Height));

                e.Graphics.FillRectangle(SystemBrushes.Highlight, r);

               e.Graphics.DrawString(e.CellText, treeList1.Font, SystemBrushes.HighlightText, r);

                e.Handled = true;
            }
       }
复制代码
posted @ 2012-04-28 17:57  跟着阿笨一起玩.NET  阅读(2064)  评论(0编辑  收藏  举报