안인권 wrote:
> 스트링그리드에서 엔터키로 다음줄의 4번째 컬럼으로 이동하는 기능을 구현해야 하는데
> 어떻게 해야할지 알려주셨으면 감사하겠습니다
아래 소스는 "StringGrid에서 Enter Key를 Tab Key와 같은 효과" 인데
조금 고치시면 가능할것 같은데...
// StringGrid의 row, col 프로퍼티를 조사한후
// 특정위치로 보내려면 마찬가지로 row, col 프로퍼티를
// 임의로 변경하면 됩니다.
// 아래는 StringGrid의 전체 cell을 여행하는 코드입니다.
procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
Key := #0;
with StringGrid1 do
if Col < ColCount-1 then {다음 column}
Col := Col + 1
else if Row < RowCount-1 then {다음 Row}
begin
Row := Row + 1;
Col := 1;
end
else
begin {Grid의 끝이면 Top으로}
Row := 1;
Col := 1;
end;
end;
end;