怎摸样让stringgrid的某行某列获得焦点,十万火急,在线等待!

smallpigs 2003-09-11 10:41:53
假如我现在的焦点在stringgrid1的第2列 第3行上,现在我编辑这个数据,而且我在SelectCell中写了判断数据合法性的函数,当我编辑完这个数据后焦点转移时候,如果数据不正确,我想让焦点再次回到我编辑的这个数据上,怎摸处理。
...全文
94 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
smallpigs 2003-09-11
  • 打赏
  • 举报
回复
谢谢邦助,但是我要在SelectCell事件中做这个处理,但是焦点没有办法回到上一格编辑的单元中,郁闷。。。:( 而且StringGrid1.Row := 2; StringGrid1.Col := 4;本身触发selectcell事件, 中秋节也过不好,烦
linzi 2003-09-11
  • 打赏
  • 举报
回复
StringGrid1.Row := 2;
StringGrid1.Col := 4;
Shiyl 2003-09-11
  • 打赏
  • 举报
回复
var
Column, Row: Longint;
procedure TForm1.StringGrid1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
StringGrid1.MouseToCell(X, Y, Column, Row);
showmessage(inttostr( column));
showmessage(inttostr(row));
end;
---------------------------------------
以上部分得到编辑的单元格的行列值。
procedure TForm1.Button1Click(Sender: TObject);
var flag:boolean;
begin
flag:=false;
if flag=False then
begin
showmessage('wrong');
stringgrid1.Cells[column,row]:='';
stringgrid1.SetFocus;
end;
end;
没有调试,试试看
wweijie 2003-09-11
  • 打赏
  • 举报
回复
var
myRect: TGridRect;
begin
myRect.Left := 3;
myRect.Top := 1;
myRect.Right := 3;
myRect.Bottom := 1;
StringGrid1.Selection := myRect;
end;

2,497

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 数据库相关
社区管理员
  • 数据库相关社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧