开发者论坛

 找回密码
 注册 (请使用非IE浏览器)
查看: 2752|回复: 0

TreeList点击后背景色及区域

[复制链接]

0

精华

145

贡献

25

赞扬

帖子
59
软币
379
在线时间
74 小时
注册时间
2017-5-10
发表于 2017-6-9 22:15:22 | 显示全部楼层 |阅读模式
[C#] 纯文本查看 复制代码
//在绘制节点时设置点击后的背景色及选中宽度
        private void BlankTreeList_CustomDrawNodeCell(object sender, CustomDrawNodeCellEventArgs e)
        {
            TreeList tree = sender as TreeList;
            if (e.Node == tree.FocusedNode)
            {
                e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
                Rectangle rect = new Rectangle(e.EditViewInfo.ContentRect.Left,
                    e.EditViewInfo.ContentRect.Top,
                    Convert.ToInt32(e.Graphics.MeasureString(e.CellText, BlankTreeList.Font).Width + 1),
                    Convert.ToInt32(e.Graphics.MeasureString(e.CellText, BlankTreeList.Font).Height + 1));
                e.Graphics.FillRectangle(SystemBrushes.Highlight, rect);
                e.Graphics.DrawString(e.CellText, BlankTreeList.Font, SystemBrushes.HighlightText, rect);
                e.Handled = true;

            }
        }

回复

使用道具 举报

Archiver|手机版|小黑屋|开发者网 ( 苏ICP备08004430号-2 )
版权所有:南京韵文教育信息咨询有限公司

GMT+8, 2024-4-26 05:52

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表