delphi – 如何为尚不存在的节点显示虚拟树视图网格线?
发布时间:2020-12-15 09:28:16 所属栏目:大数据 来源:网络整理
导读:我在Delphi 7中使用SoftGem的VirtualStringTree. 有没有办法启用完整的网格线(就像在TListView中一样)?我只能找到toShowHorzGridLines,它只显示当前节点的行,而不是下面空白空间中的任何内容,以及toShowVertGridLines,它只显示垂直线. 如何在添加项目之前在
我在Delphi 7中使用SoftGem的VirtualStringTree.
有没有办法启用完整的网格线(就像在TListView中一样)?我只能找到toShowHorzGridLines,它只显示当前节点的行,而不是下面空白空间中的任何内容,以及toShowVertGridLines,它只显示垂直线. 如何在添加项目之前在空白区域中显示它们? 解决方法
我不认为有一种简单的方法可以在不修改PaintTree方法的情况下实现它,因为没有任何节点事件无法触发,因为应该简单绘制线条的节点尚不存在.
这是一种肮脏的方法,如何根据最低可见节点另外绘制水平线.实际上,它在此屏幕截图中绘制了由橙色填充的区域中DefaultNodeHeight值的距离: 这是代码: type TVirtualStringTree = class(VirtualTrees.TVirtualStringTree) public procedure PaintTree(TargetCanvas: TCanvas; Window: TRect; Target: TPoint; PaintOptions: TVTInternalPaintOptions; PixelFormat: TPixelFormat = pfDevice); override; end; implementation { TVirtualStringTree } procedure TVirtualStringTree.PaintTree(TargetCanvas: TCanvas; Window: TRect; Target: TPoint; PaintOptions: TVTInternalPaintOptions; PixelFormat: TPixelFormat); var I: Integer; EmptyRect: TRect; PaintInfo: TVTPaintInfo; begin inherited; if (poGridLines in PaintOptions) and (toShowHorzGridLines in TreeOptions.PaintOptions) and (GetLastVisible <> nil) then begin EmptyRect := GetDisplayRect(GetLastVisible,Header.Columns[Header.Columns.GetLastVisibleColumn].Index,False); EmptyRect := Rect(ClientRect.Left,EmptyRect.Bottom + DefaultNodeHeight,EmptyRect.Right,ClientRect.Bottom); ZeroMemory(@PaintInfo,SizeOf(PaintInfo)); PaintInfo.Canvas := TargetCanvas; for I := 0 to ((EmptyRect.Bottom - EmptyRect.Top) div DefaultNodeHeight) do begin PaintInfo.Canvas.Font.Color := Colors.GridLineColor; DrawDottedHLine(PaintInfo,EmptyRect.Left,EmptyRect.Top + (I * DefaultNodeHeight)); end; end; end; 这里有恒定和变量节点高度的结果: 上面屏幕截图中可见的毛刺(从左侧偏移的线条)只是虚线渲染的结果.如果将虚拟树视图上的LineStyle属性设置为lsSolid,则会看到正确的结果. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- Lua bind for C 和 conf 实现
- 在docka api的golang sdk中为ContainerCreate函数设置PortB
- 《Lua设计与实现》的作者codedump:学习也要讲究性价比
- Golang GAE – HTML模板没有正确地将链接插入网页
- Delphi XE8 手动配置Android开发环境JDK,Android SDK,NDK
- delphi中利用Indy的TIdFtp控件实现FTP协议
- 如何在Spring MVC测试中设置Web应用程序上下文
- perl – 有没有办法比较Template Toolkit中的两个变量?
- Golang Web 框架 Beego 静态文件处理 - 07
- Nebula3的渲染线程插件(Render Thread Plugin)