
14.11.2008, 19:12
|
Модератор
|
|
Регистрация: 17.04.2008
Сообщения: 8,106
Версия Delphi: 7, XE3, 10.2
Репутация: 49089
|
|
Да уж куда проще-то???
Код:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids;
type
TForm1 = class(TForm)
StringGrid1: TStringGrid;
procedure StringGrid1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
FState : Integer;
FSel : TPoint;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.StringGrid1Click(Sender: TObject);
begin
Case FState Of
1 : // No selected
Begin
FSel.X := StringGrid1.Col;
FSel.Y := StringGrid1.Row;
FState := 2;
Exit;
End;
2 : // 1 selected
Begin
If StringGrid1.Cells[StringGrid1.Col,StringGrid1.Row] = StringGrid1.Cells[FSel.X,FSel.Y] Then
Begin
StringGrid1.Cells[StringGrid1.Col,StringGrid1.Row] := '';
StringGrid1.Cells[FSel.X,FSel.Y] := '';
End;
FState := 1;
Exit;
End;
End;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
FState := 1;
end;
end.
|