Einzelnen Beitrag anzeigen

Hansa

Registriert seit: 9. Jun 2002
Ort: Saarland
7.554 Beiträge
 
Delphi 8 Professional
 
#4

Re: im Stringgrid Zellen total sperren

  Alt 17. Nov 2004, 17:19
Es sieht jetzt so aus :

Delphi-Quellcode:
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.RowCount := StringGrid1.RowCount + 1;
      StringGrid1.Row := StringGrid1.Row + 1; // jetzt erst Row und Col setzen !!
      StringGrid1.Col := 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[1,ARow]) = '';
      end
      else if (Acol = 4) then begin
// z := (Trim (Cells[1,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;
Die auskommentierte Zeile ********** funktioniert nicht. Kennt denn keiner sich mit der Delphi-Komponente Stringgrid aus ?
Gruß
Hansa
  Mit Zitat antworten Zitat