procedure TInputForm.strgCostKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if (key=13) and (strgCost.Row<strgCost.RowCount-1) then if strgCost.Col=strgCost.Cols then begin strgCost.Row:=strgCost.Row+1; strgCost.Col:=1; end else strgCost.Col:=strgCost.Col+1; end;
对不起搞错了,应该是: procedure TInputForm.strgCostKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if (key=13) and (strgCost.Row<strgCost.RowCount-1) then if strgCost.Col=strgCost.ColCount-1 then begin strgCost.Row:=strgCost.Row+1; strgCost.Col:=1; end else strgCost.Col:=strgCost.Col+1; end;
if key=chr(vk_return) then if dbgrid1.selectedIndex=dbgrid1.Columns.Count-1 then dbgrid1.selectedIndex=0 else dbgrid1.selectedIndex=dbgird1.selectedIndex+1;
刚才没经过测试,最终版本,呵呵 procedure TForm1.strgCostKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if (key=13) then if (strgCost.Row=strgCost.RowCount-1) and (strgCost.Col=strgCost.ColCount-1) then Exit; if (strgCost.Col=strgCost.ColCount-1) then begin strgCost.Row:=strgCost.Row+1; strgCost.Col:=1; end else strgCost.Col:=strgCost.Col+1; end;
if(key=#13)then
keybd_event(vk_tab,0,0,0);
Shift: TShiftState);
begin
if (key=13) and (strgCost.Row<strgCost.RowCount-1) then
if strgCost.Col=strgCost.Cols then begin
strgCost.Row:=strgCost.Row+1;
strgCost.Col:=1;
end
else
strgCost.Col:=strgCost.Col+1;
end;
procedure TInputForm.strgCostKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key=13) and (strgCost.Row<strgCost.RowCount-1) then
if strgCost.Col=strgCost.ColCount-1 then begin
strgCost.Row:=strgCost.Row+1;
strgCost.Col:=1;
end
else
strgCost.Col:=strgCost.Col+1;
end;
if dbgrid1.selectedIndex=dbgrid1.Columns.Count-1 then
dbgrid1.selectedIndex=0
else
dbgrid1.selectedIndex=dbgird1.selectedIndex+1;
procedure TForm1.strgCostKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (key=13) then
if (strgCost.Row=strgCost.RowCount-1) and (strgCost.Col=strgCost.ColCount-1) then
Exit;
if (strgCost.Col=strgCost.ColCount-1) then begin
strgCost.Row:=strgCost.Row+1;
strgCost.Col:=1;
end
else
strgCost.Col:=strgCost.Col+1;
end;