在stringgrid中如何实现按Enter键光标跳到下一网格?
解决方案 »
- 关于线程和一小问题.
- rxrichedit插入图片后,这个图片是什么?怎么在程序中对这个图片进行操作?
- ****************兰州地区高薪城聘DElphi程序员(2000~5000/月+提成)****************
- 【双百求助】请教:控件中为什么不能有菜单、、
- 一个关于TreeView刷新的问题!
- 菜鸟问题:TRY。。。。EXCEPT。。。END的问题(在线等待100分)
- 一个弱弱的容器类问题
- @@@--请问怎么在NT下创建活动目录,高分!外加请吃饭!--@@@
- Form 不显示出来,然而编译可以通过(编译的时候Form 就有了),搜索路径又是对的
- 如何监控键盘按下了那个键
- 一个关于数据保存的问题。
- 三层中存储过程的调用问题!做过三层的帮忙进来看看!
if key = VK_ENTER then key = VK_TAP
if key = VK_ENTER then key = VK_TAB
procedure TForm1.StringGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if key= VK_RETURN then
begin
if StringGrid1.Selection.Right>= StringGrid1.ColCount-1 then
key:=VK_DOWN
else
key:=VK_RIGHT;
end;
end;
procedure TForm1.StringGrid1KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
var
GridRect : TGridRect;
begin
if key= VK_RETURN then
begin
if StringGrid1.Selection.Right>= StringGrid1.ColCount-1 then
begin
GridRect.Left :=1;
GridRect.Top := StringGrid1.Selection.Top+1;
GridRect.Right:=1;
GridRect.Bottom :=StringGrid1.Selection.Bottom+1;
StringGrid1.Selection := GridRect;
end
else
key:=VK_RIGHT;
end;
end;
if key = VK_ENTER then key = VK_TAB
在stringGrid的OnKeyUp中增加如下代码:
if StringG2.col < StringG2.colCount then
StringG2.Col := StringG2.Col + 1;//列向移动
if StringG2.Row < StringG2.RowCount then
StringG2.Row := StringG2.Row + 1;//行移动
Shift: TShiftState);
begin
if StringGrid1.col < StringGrid1.colCount-1 then
StringGrid1.Col := StringGrid1.Col + 1//列向移动
else if StringGrid1.Row < StringGrid1.RowCount-1 then
begin
StringGrid1.Row := StringGrid1.Row + 1;//行移动
StringGrid1.Col :=1;
end;
end;