📄 testeditdetailform.pas
字号:
unit TestEditDetailForm;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
Buttons, DB, DBTables, Grids, ComCtrls, DBGrids, DBCGrids, ExtCtrls, DBCtrls,
StdCtrls, Mask, dbTree, TestSelectForm, TreeVwEx;
type
TfrmEditDetail = class(TForm)
Table1: TTable;
DataSource1: TDataSource;
DBTreeView1: TDBTreeView;
Table1ID: TIntegerField;
Table1Parent: TIntegerField;
Table1Text: TStringField;
DBNavigator1: TDBNavigator;
BitBtn1: TBitBtn;
Label1: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
end;
var
frmEditDetail: TfrmEditDetail;
implementation
{$R *.DFM}
procedure OpenTable(Table: TTable);
var
TableName: String;
begin
if Table.Active then
exit;
if (Table.DatabaseName = '') then
begin
TableName := Table.TableName;
if (Pos('.DB', UpperCase(TableName)) = 0) then
TableName := TableName + '.DB';
if FileExists(ExtractFilePath(Application.ExeName) +
TableName) then
Table.DatabaseName := ExtractFileDir(Application.ExeName)
else
begin
ShowMessage(
'Please set ' + Table.Name + '.DatabaseName to the location of ' +
TableName + ' or copy ' + TableName +
' to the location of ' + Application.ExeName);
halt;
end;
end;
Table.Open;
end;
procedure TfrmEditDetail.FormCreate(Sender: TObject);
begin
try
OpenTable(Table1);
finally
{ We better stop the demo if something is wrong: }
if not (Table1.Active) then
halt;
end;
end;
procedure TfrmEditDetail.FormCloseQuery(Sender: TObject;
var CanClose: Boolean);
begin
with Table1 do
if (State in [dsEdit, dsInsert]) then
case MessageDlg('Save changes ?', mtConfirmation, mbYesNoCancel, 0) of
mrYes: Post;
mrNo: Cancel;
else CanClose := false;
end;
end;
end.
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -