unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids;
type
TForm1 =
class(TForm)
StringGrid1: TStringGrid;
procedure StringGrid1KeyPress(Sender: TObject;
var Key: Char);
procedure StringGrid1SelectCell(Sender: TObject; ACol, ARow: Integer;
var CanSelect: Boolean);
procedure FormShow(Sender: TObject);
private
{ Private-Deklarationen }
AktRow : integer;
function ZelleZulaessig(ACol,ARow: integer): boolean;
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
uses hauptmod;
{$R *.dfm}
procedure TForm1.StringGrid1KeyPress(Sender: TObject;
var Key: Char);
begin
if (key = #13)
then begin
if StringGrid1.Col = 1
then
StringGrid1.Col := 4
else begin
StringGrid1.Col := 1;
StringGrid1.RowCount := StringGrid1.RowCount + 1;
StringGrid1.Row := StringGrid1.Row + 1;
end
end;
end;
function TForm1.ZelleZulaessig (ACol,ARow: integer): boolean;
var z : boolean;
begin
z := false;
if ACol
in [1,4]
then with StringGrid1
do begin
z := AktRow = ARow;
// zumindest mal die richtige Zeile !
if z
then begin // jetzt kommt Spalte dran
if ACol = 1
then begin
z := Trim (Cells[ACol,ARow]) = '
';
end;
end;
end;
ZelleZulaessig := z;
end;
procedure TForm1.StringGrid1SelectCell(Sender: TObject; ACol,
ARow: Integer;
var CanSelect: Boolean);
begin
if AktRow < ARow
then
AktRow := ARow;
Canselect := ZelleZulaessig(ACol,ARow);
end;
procedure TForm1.FormShow(Sender: TObject);
begin
AktRow := 0;
end;
end.