1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
|
procedure TForm1.StringGrid1MouseDown(Sender: TObject;
Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
var ACol,ARow:Longint;
begin
StringGrid1.MouseToCell(X,Y,ACol,ARow);
if button=mbLeft then StringGrid1.cells[ACol,ARow]:='M';
if button=mbright then StringGrid1.cells[ACol,ARow]:='V';
end;
procedure TForm1.StringGrid1DrawCell(Sender: TObject; ACol, ARow: Integer;
Rect: TRect; State: TGridDrawState);
begin
with StringGrid1.Canvas do
begin
Brush.Color:=clwhite;
if StringGrid1.cells[ACol,ARow]='M'then Brush.Color:=clred;
if StringGrid1.cells[ACol,ARow]='V'then Brush.Color:=cllime;
fillrect(rect);
end;
end; |