| 这个最先是发在朋友的网站 www.lihuasoft.net 上的,大家可以看看: 原来StringGrid的演示效果:
修改后的StringGrid的演示效果:
{** * 单元:DotLineGrid * 作者:网事如风 * 作用:实现虚线的StringGrid * 使用: **}
unit DotLineGrid; ![]() interface ![]() uses SysUtils, Classes, Controls, Grids, Types, Graphics; ![]() type tDotLineGrid
=
class(TStringGrid) private
{ Private declarations }
protected
{ Protected declarations }
procedure DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); override; public
{ Public declarations }
published
{ Published declarations }
end; ![]() procedure Register; ![]() implementation ![]() procedure Register; begin RegisterComponents(
'
Samples
'
, [tDotLineGrid]); end; ![]() procedure tDotLineGrid.DrawCell(ACol, ARow: Longint; ARect: TRect; AState: TGridDrawState); Var I, TmpWidth : Integer; begin Canvas.Pen.Color :
=
clblack; Canvas.Pen.Style :
=
psSolid; inherited DrawCell(ACol, ARow, ARect, AState); ![]() TmpWidth :
=
0
;
for
I :
=
1
to RowCount
do
begin
if
( (I
>
0
) and (not odd( I ) ) ) then begin
//
Canvas.Pen.Color := clblack;
Canvas.Pen.Style :
=
psDot; end
else
begin
//
Canvas.Pen.Color := clblack;
Canvas.Pen.Style :
=
psSolid; end; ![]() Inc(TmpWidth, RowHeights[I
-
1
]
+
1
); Canvas.MoveTo(
0
, TmpWidth
-
1
); Canvas.LineTo( Width, TmpWidth
-
1
); end; ![]() TmpWidth :
=
0
;
for
I :
=
1
to ColCount
do
begin Inc(TmpWidth, ColWidths[I
-
1
]
+
1
); Canvas.MoveTo( TmpWidth
-
1
,
0
); Canvas.LineTo( TmpWidth
-
1
, Width ); end; end; ![]() end.
|
控件:实现虚线的StringGrid
最新推荐文章于 2025-07-10 10:32:30 发布
博客围绕整数(integer)、接口(interface)、类型(types)和类(class)展开,但具体内容缺失。推测可能涉及这些信息技术概念的特性、应用等方面。




unit DotLineGrid;
2698

被折叠的 条评论
为什么被折叠?



