H
hqh79
Unregistered / Unconfirmed
GUEST, unregistred user!
我想在DrawGrid1中实现,点击一下DrawGrid1,所选中的cell的原来颜色是Clwindows则让其变为红色,否则让其变为Clwindows。
procedure TForm1.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
x,y:integer;
begin
ARow:=DrawGrid1.Row;
ACol:=DrawGrid1.Col;
x:=ACol*DrawGrid1.DefaultColWidth+3;
y:=ARow*DrawGrid1.DefaultRowHeight+3;
if DrawGrid1.Canvas.Pixels[x,y]=Clred then
DrawGrid1.Canvas.Brush.Color:=clWindow
else
DrawGrid1.Canvas.Brush.Color:=Clred;
DrawGrid1.Canvas.FillRect(DrawGrid1.CellRect(ACol,ARow));
end;
但DrawGrid1.Canvas.Pixels[x,y]总返回-1?
有什么其它更好的办法实现?
procedure TForm1.DrawGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
var
x,y:integer;
begin
ARow:=DrawGrid1.Row;
ACol:=DrawGrid1.Col;
x:=ACol*DrawGrid1.DefaultColWidth+3;
y:=ARow*DrawGrid1.DefaultRowHeight+3;
if DrawGrid1.Canvas.Pixels[x,y]=Clred then
DrawGrid1.Canvas.Brush.Color:=clWindow
else
DrawGrid1.Canvas.Brush.Color:=Clred;
DrawGrid1.Canvas.FillRect(DrawGrid1.CellRect(ACol,ARow));
end;
但DrawGrid1.Canvas.Pixels[x,y]总返回-1?
有什么其它更好的办法实现?