unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, Forms, Controls, Grids, StdCtrls, Types;
type
{ TForm1 }
TForm1 = class(TForm)
Memo1: TMemo;
StringGrid1: TStringGrid;
procedure FormCreate(Sender: TObject);
procedure Memo1Change(Sender: TObject);
procedure StringGrid1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
procedure StringGrid1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
private
public
end;
var
Form1: TForm1;
Inside: boolean;
implementation
{$R *.lfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
StringGrid1.AllowOutboundEvents := False;
end;
procedure TForm1.StringGrid1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
Memo1.Append('MOUSEDOWN');
if Y < StringGrid1.CellRect(0, StringGrid1.RowCount-1).Bottom then
begin
Inside := true;
Memo1.Append('ROW CLICKED');
StringGrid1.Options := StringGrid1.Options + [goAlwaysShowEditor,goAutoAddRows, goRowHighlight,goEditing,goColSpanning,goRelaxedRowSelect,goTabs];
StringGrid1.Options := StringGrid1.Options - [goRangeSelect];
StringGrid1.ExtendedSelect := False;
StringGrid1.Refresh;
end
else
begin
Memo1.Append('DEAD SPACE');
Memo1.Append('CLEAR SELECTIONS');
StringGrid1.ClearSelections;
Inside := False;
end;
end;
procedure TForm1.StringGrid1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if (Inside = false) then
begin
StringGrid1.Options := StringGrid1.Options - [goAlwaysShowEditor,goAutoAddRows, goRowHighlight,goEditing,goColSpanning,goRelaxedRowSelect,goTabs];
StringGrid1.Options := StringGrid1.Options + [goRangeSelect];
StringGrid1.ExtendedSelect := True;
StringGrid1.Refresh;
Memo1.SetFocus;
end;
end;
procedure TForm1.Memo1Change(Sender: TObject);
begin
Memo1.CaretPos := Point(0, Memo1.Lines.Count-1)
end;
end.