StringGrid通过回车键切换单元格。
procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);
begin
if Key=#13 then
begin
With StringGrid1 do
begin
if Col<ColCount-1 then
begin
Col:=Col+1;
end
else//换行
if Row<RowCount-1 then
begin
Row:=Row+1;
Col:=0;
end
else //回到第一个单元格
if (Row=RowCount-1) and (Col=ColCount-1) then
begin
Row:=0;
Col:=0;
end;
end;
end;
end;
本文介绍了一个使用Delphi编写的程序片段,该程序使StringGrid能够通过回车键进行单元格间的切换。具体实现包括在同一行内移动到下一个单元格、移到下一行的首个单元格以及在到达表格边界时返回到起始单元格。

被折叠的 条评论
为什么被折叠?



