1.在TDBGrid中将Enter键用作Tab键
//设置窗体的KeyPreview为True
procedure TForm1.FormKeyPress(Sender: Tobject; var Key: Char);
begin if Key = #13 then if not (ActiveControl is TDBGrid) then begin Key := #0; Perform(WM_NEXTDLGCTL, 0, 0); end else if (ActiveControl is TDBGrid) then with TDBGrid(ActiveControl) do if selectedindex $#@60; (fieldcount -1) then selectedindex := selectedindex +1 else selectedindex := 0;
end;
2.删除记录前显示汉语的提示对话框
//设置DbNavigator的ConfirmDelete属性为False //在数据集控件的BeforeDelete事件中编写如下代码:
if Application.MessageBox("确定要删除当前记录吗?", "删除 记录", Mb_YesNo + Mb_IconWarning) = Id_No then Abort; //利用哑异常退出删除事件
|