unit object_grid;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, pobject_base, DBTables, ImgList, DB, Wwquery, Wwdatsrc,
ComCtrls, ToolWin,inifiles, ExtCtrls, Mask, DBCtrls, Grids, Wwdbigrd,
Wwdbgrid, StdCtrls, Wwkeycb;
type
Tobject_gridf = class(Tobject_base)
panleft: TPanel;
pantop: TPanel;
Label1: TLabel;
findkey: TwwIncrementalSearch;
dataDBGrid: TwwDBGrid;
panright: TPanel;
Splitter1: TSplitter;
procedure savedata;override;
procedure deletedata;override;
procedure FormClose(Sender: TObject;
var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
procedure remarkEnter(Sender: TObject);
procedure remarkExit(Sender: TObject);
procedure Btn_AppendClick(Sender: TObject);
procedure Btn_modifyClick(Sender: TObject);
procedure Btn_CancelClick(Sender: TObject);
procedure Btn_SaveClick(Sender: TObject);
procedure dataDBGridEnter(Sender: TObject);
procedure dataDBGridExit(Sender: TObject);
private
inifile:tinifile;
//vmaoedit;20021118
{ Private declarations }
public
{ Public declarations }
end;
var
object_gridf: Tobject_gridf;
implementation
uses uejxc, Pdlgloading;
{$R *.dfm}
procedure Tobject_gridf.deletedata;
begin
inherited;
data_master.Delete;
//缓存在object_base提交
end;
procedure Tobject_gridf.FormClose(Sender: TObject;
var Action: TCloseAction);
begin
inherited;
//写窗体配置文件
if self.BorderStyle=bsSizeToolWin then
begin
//窗体
inifile.writeInteger(self.Name,'width',self.Width);
inifile.writeInteger(self.Name,'height',self.Height);
//panel
inifile.writeInteger(self.Name,'panleftw',tpanel(self.FindComponent('panleft')).Width);
inifile.writeInteger(self.Name,'panlefth',tpanel(self.FindComponent('panleft')).Height);
//在close中写配置和释放文件;
inifile.UpdateFile;
inifile.Free;
end;
//写配置文件;
datadbgrid.SaveToIniFile;
end;
procedure Tobject_gridf.FormCreate(Sender: TObject);
var w,h:integer;
begin
inherited;
//读窗体配置文件
if self.BorderStyle=bsSizeToolWin then
begin
inifile:=tinifile.Create(pu_path+'/ini/form.ini');
//窗体
w:=inifile.ReadInteger(self.Name,'width',0);
if w>0 then
self.Width:=w;
h:=inifile.ReadInteger(self.Name,'height',0);
if h>0 then
self.Height:=h;
//panel
w:=inifile.ReadInteger(self.Name,'panleftw',0);
if w>0 then
tpanel(self.FindComponent('panleft')).Width:=w;
h:=inifile.ReadInteger(self.Name,'panlefth',0);
if h>0 then
tpanel(self.FindComponent('panleft')).Height:=h;
//在close中写配置和释放文件;
end;
datadbgrid.IniAttributes.FileName:=pu_path+'/ini/datadbgrid.ini';
datadbgrid.IniAttributes.SectionName:=Name;
datadbgrid.LoadFromIniFile;
with Dlgloading.Progressdo
Position:=Position+20;
data_master.Open;
with Dlgloading.Progressdo
Position:=Position+40;
end;
procedure Tobject_gridf.savedata;
begin
inherited;
data_master.Post;
end;
procedure Tobject_gridf.FormShow(Sender: TObject);
begin
inherited;
findkey.SearchField:=datadbgrid.Fields[0].FieldName;
end;
procedure Tobject_gridf.remarkEnter(Sender: TObject);
begin
EditEnter(sender);
keypreview:=false;
end;
procedure Tobject_gridf.remarkExit(Sender: TObject);
begin
EditExit(sender);
keypreview:=true;
end;
procedure Tobject_gridf.Btn_AppendClick(Sender: TObject);
begin
panright.Enabled:=true;
panleft.Enabled:=false;//问题在这里,wwdbgrid在panel上,所以panel的enabled=false要在inherited之前 inherited中有dataset.append;
系统默认inherited在最前是不对的!
inherited;
end;
procedure Tobject_gridf.Btn_modifyClick(Sender: TObject);
begin
panright.Enabled:=true;
panleft.Enabled:=false;
inherited;
end;
procedure Tobject_gridf.Btn_CancelClick(Sender: TObject);
begin
panright.Enabled:=false;
panleft.Enabled:=true;
inherited;
end;
procedure Tobject_gridf.Btn_SaveClick(Sender: TObject);
begin
inherited;
if not btn_save.Enabled then
begin
panright.Enabled:=false;
panleft.Enabled:=true;
end;
end;
procedure Tobject_gridf.dataDBGridEnter(Sender: TObject);
begin
inherited;
keypreview:=false;
end;
procedure Tobject_gridf.dataDBGridExit(Sender: TObject);
begin
inherited;
keypreview:=true;
end;
end.