D
Dk108
Unregistered / Unconfirmed
GUEST, unregistred user!
刚做了个控件,想在DrawGrid的每一行的第一列加上一个CheckBox,但是编译以后每次添加
到一个Form上,在DrawGrid上都有闪烁,而且运行也看不到CheckBox,那位高手能帮我看看是什么
原因!
unit XzlDrawGrid;
interface
uses
windows,SysUtils,Classes,Grids,Graphics,Messages,Controls,StdCtrls,Forms;
type
TXzlDrawGrid=class(TDrawGrid)
private
fcolor:TColor;
procedure setcolor(const value:TColor);
public
CheckBox:Array[1..100]of TCheckBox;
constructor Create(AOwner:TComponent);override;
destructor Destroy;override;
procedure DrawCell(ACol,ARow:LongInt;ARect:TRect;AState:TGridDrawState);override;
published
property mycolor:TColor read fcolor write setcolor;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples',[TXzlDrawGrid]);
end;
constructor TXzlDrawGrid.Create(AOwner:TComponent);
var
i:integer;
begin
inherited Create(AOwner);
FColor := clBtnFace;
for i:=1 to col do
CheckBox:=TCheckBox.create(Self);
end;
destructor TXzlDrawGrid.Destroy;
begin
inherited;
end;
procedure TXzlDrawGrid.setcolor(const value:TColor);
begin
Fcolor:=value;
refresh;
end;
procedure TXzlDrawGrid.DrawCell(ACol,ARow:LongInt;ARect:TRect;AState:TGridDrawState);
begin
if (ACol=1)and(ARow<>0) then
begin
CheckBox[ACol].Parent:=Self;
CheckBox[ACol].Left:=ARect.Left;
CheckBox[ACol].Top:=ARect.Top;
CheckBox[ACol].Height:=ARect.Bottom-ARect.Top;
CheckBox[ACol].Show;
end;
inherited;
end;
end.
到一个Form上,在DrawGrid上都有闪烁,而且运行也看不到CheckBox,那位高手能帮我看看是什么
原因!
unit XzlDrawGrid;
interface
uses
windows,SysUtils,Classes,Grids,Graphics,Messages,Controls,StdCtrls,Forms;
type
TXzlDrawGrid=class(TDrawGrid)
private
fcolor:TColor;
procedure setcolor(const value:TColor);
public
CheckBox:Array[1..100]of TCheckBox;
constructor Create(AOwner:TComponent);override;
destructor Destroy;override;
procedure DrawCell(ACol,ARow:LongInt;ARect:TRect;AState:TGridDrawState);override;
published
property mycolor:TColor read fcolor write setcolor;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Samples',[TXzlDrawGrid]);
end;
constructor TXzlDrawGrid.Create(AOwner:TComponent);
var
i:integer;
begin
inherited Create(AOwner);
FColor := clBtnFace;
for i:=1 to col do
CheckBox:=TCheckBox.create(Self);
end;
destructor TXzlDrawGrid.Destroy;
begin
inherited;
end;
procedure TXzlDrawGrid.setcolor(const value:TColor);
begin
Fcolor:=value;
refresh;
end;
procedure TXzlDrawGrid.DrawCell(ACol,ARow:LongInt;ARect:TRect;AState:TGridDrawState);
begin
if (ACol=1)and(ARow<>0) then
begin
CheckBox[ACol].Parent:=Self;
CheckBox[ACol].Left:=ARect.Left;
CheckBox[ACol].Top:=ARect.Top;
CheckBox[ACol].Height:=ARect.Bottom-ARect.Top;
CheckBox[ACol].Show;
end;
inherited;
end;
end.