怎么在cxGrid中的某一个单元格回车?而且回车后还是在该列上?
步骤:
1:设置需要回车的字段。程序运行时需要让cxGrid获得焦点时,该字段就要为选中状态。
procedure TForm1.cxGrid1Enter(Sender: TObject);
begin
Self.cxGrid1DBTableView1.GetColumnByFieldName('收费金额').Focused:=True;
end;
2:
procedure TForm1.cxGrid1DBTableView1KeyPress(Sender: TObject; var Key: Char);
begin
if key=#13 then
begin
if cxGrid1DBTableView1.DataController.IsEOF then
begin
Self.Button1.SetFocus;
Exit;
end;//如果已经是最后一行了,自然转出输入焦点
cxGrid1DBTableView1.DataController.GotoNext;
end;
end;
本文介绍如何在cxGrid的指定单元格中通过回车键进行操作,并保持输入焦点在同一列。首先设置需要响应回车键的字段,然后通过键盘事件捕获回车键并控制数据导航。
518

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



