怎麼在cxGrid中的某一個單元格回車?

 

怎麼在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;

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章