type
TForm1 = class(TForm)
DBGrid1: TDBGrid;
Table1: TTable;
DataSource1: TDataSource;
DBNavigator1: TDBNavigator;
procedure DBGrid1ColEnter(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private-Deklarationen }
public
Procedure Weiter;
function Alle: Boolean;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
var
Sperre: set of byte = [1, 3, 7]; // z.B.
NextLine: Boolean = True;
Fehler: Boolean;
function TForm1.Alle: Boolean;
var
I: integer;
begin
Result := True;
for I := 0 to DBGrid1.Columns.Count - 1 do
if not(I in Sperre) then
begin
Result := False;
Break;
end;
end;
procedure TForm1.Weiter;
var
I, I2: integer;
begin
if Fehler then
exit;
I := DBGrid1.SelectedField.Index;
if I in Sperre then
begin
if I = pred(DBGrid1.Columns.Count) then
begin
I2 := 0;
while I2 in Sperre do
inc(I2);
if NextLine then
begin
DBGrid1.DataSource.Dataset.Next;
if DBGrid1.DataSource.Dataset.Eof then
DBGrid1.DataSource.Dataset.first;
end;
end
else
I2 := succ(I);
DBGrid1.SelectedField := DBGrid1.Fields[I2];
end;
end;
procedure TForm1.DBGrid1ColEnter(Sender: TObject);
begin
Weiter;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Fehler := Alle;
if Alle then
ShowMessage('Es dürfen nicht alle Spalten gesperrt werden!')
else
Weiter;
end;