求stringgrid按回车下移单元格(50分)

  • 主题发起人 主题发起人 ohmymother
  • 开始时间 开始时间
O

ohmymother

Unregistered / Unconfirmed
GUEST, unregistred user!
在stringgrid控件中,如何实现像dbgrid控件中按下回车键,光标能自动移到下一单元格?按向下键,dbgrid的行数自动增加?
 
2003-11-17 16:37:15 在stringGrid中使用回车键模拟TAB键切换单元格的功能实现......
procedure TForm1.StringGrid1KeyPress(Sender: TObject; var Key: Char);
label
nexttab;
begin
if key=#13 then
begin
key:=#0;
nexttab:
if (stringgrid1.Col<stringgrid1.ColCount-1) then
begin
stringgrid1.Col:=stringgrid1.Col+1;
end
else
begin
if stringgrid1.Row>=stringgrid1.RowCount-1 then
stringgrid1.RowCount:=stringgrid1.rowCount+1;
stringgrid1.Row:=stringgrid1.Row+1;
stringgrid1.Col:=0;
goto nexttab;
end;
end;
end;

这里面可以加一个关于按向下键的,那么你把stringgrid的rows设置为原来的+1即可多一行了.
 
好不容易有个会的,又来晚了,
 
其实就是 sg.cells[col,row] 的操作
 
其实我看过这个N遍,我是想向下移不是向右移.
忽然反应过来行和列是一样的...........
 
if Key = #13 then
begin
stringgrid1.row :=stringgrid1.row +1;
end;
 

Similar threads

S
回复
0
查看
838
SUNSTONE的Delphi笔记
S
D
回复
0
查看
934
DelphiTeacher的专栏
D
S
回复
0
查看
799
SUNSTONE的Delphi笔记
S
D
回复
0
查看
727
DelphiTeacher的专栏
D
D
回复
0
查看
2K
DelphiTeacher的专栏
D
后退
顶部