wwDBGrid的问题。(50分)

  • 主题发起人 主题发起人 hrp123
  • 开始时间 开始时间
H

hrp123

Unregistered / Unconfirmed
GUEST, unregistred user!
wwdbgrid连接好了数据源dsMaster.并连接好了ADOQUERY界面上有一“新增‘”按钮代码为: dsMaster.DataSet.Append;
(由于我要做继承所以不写adoQuery.Append,我用的是ADO+SQL SEerver2000)
问题现象是这样:
当第一次打开这个表单击这个“新增”按钮时:wwDBGrid显示并不会进入新增状态。同时报错是:BookMark无效。之后再单击“新增”时,一切都正常,可立即进入新增状态。
 
To:Zlmlily_cn
转换+dbf 是什么意思呀麻烦你能否详细点?分就归你啦!
 
如果是表单继承的话wwdbgrid是有这个bug的!
append过程,你肯定对wwdbgrid进行了enabled=false 或 readonly=true 的操作!
你只要把
inherited语句和enabled语句的顺序调换一下就可以了!
 
To VMAO
1:我将wwdbgrid的Readonly设置为False,Enable:=True在程序中没对这两个属性进行任何设置。问题依旧。
2:我将wwdbgrid换成dbgrid ukd 问题还是存在。
 
这个就郁闷了!我以前也是继承的时候wwdbgrid有问题!后来把inherid放在上面就可以了
 
To VMAO
能否将你的基类给一份我呀?万分感谢!为此不大不小的问题郁闷的很!
szfity@163.com
 
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.
 
VMAO的回答正全我意问题果真圆MAI解决!
 
后退
顶部