Following is the sample:
if (Sender is TDBEdit) or (Sender is TFetchDBEdit) then
With TFetchDBEdit(Sender) do
begin
if not (DataSource.Dataset.State in [dsinsert,dsEdit]) then exit;
if DataSource.Dataset.FindField(DataField) is TStringField then
begin
if Length(Text) = DataSource.Dataset.FindField(DataField).Size then
SelectNext(TWincontrol(Sender),True,True);
end;
end;三少 :o)
if (Sender is TDBEdit) or (Sender is TFetchDBEdit) then
With TFetchDBEdit(Sender) do
begin
if not (DataSource.Dataset.State in [dsinsert,dsEdit]) then exit;
if DataSource.Dataset.FindField(DataField) is TStringField then
begin
if Length(Text) = DataSource.Dataset.FindField(DataField).Size then
SelectNext(TWincontrol(Sender),True,True);
end;
end;三少 :o)
2.DBnavigator跟一个Tabel关联起来就可以了。
一定要用调用它的click.
click之后再怎样呢,请说详细点。
可以将它们相同的事件定在一个事件中,如
edit1.Onkeydown=mykeydown;
edit2.onkeydown=mykeydown;
然后再在mykeydown中识别是哪个edit1.
procedure TForm1.MyKeyDown(Sender as TObject)
var ControlName:string;
begin
ControlName:=(Sender as TEdit).Name;
//注意分大小写。
if ControlName='Edit1' then
begin
...
end
else if ControlName='Edit2' then
begin
...
end;
end;
2.怎样在程序中利用TDBnavigator执行各种数据库操作。
指定它的DataSource
var DataSource:TDataSource;
procedure TForm1.Oncreate;
begin
DataSource:=TDataSource.Create(self);
DataSource.DataSet:=哪个窗体的DataSet(Table,Query);
DBnavigator1.DataSource:=DataSource;
end;
而第二个问题,难道我说的还不够清楚,再说一遍吧....不是指执行.exe后对TDBnavigator操作,而是,!!!!!!注意,是在我的程序代码中使用它完成insert,delete等等操作。TDBnavigator与数据库的连接正常。
即然连接正常,那么就像其它控件对数据库的操作一样,它的操作就是对数据库insert,delete,
都不用你写代码了
我想你的意思是想控制TDBnavigator中各个小button的功能,或是用自己的代码替代它吧
begin
case button of
nbFirst: // Go to the first record
nbPrior: // Go to the previous record
nbNext: // Go to the next record
nbLast: // Go to the last record
nbInsert: // Insert a blank record
nbDelete: // Delete the current record
nbEdit: // Permit users to edit the current record
nbPost : // Post the current record
nbCancel: // Cancel the current edit
nbRefresh: //
end;
end;
.......
.......
我的意思是
比如说:用户打开了一张表,而我要在程序中控制当这张表打开之后执行一次insert操作,而当前窗体中只有一个tnavigator(不可见,即不是给用户使用的),我该怎样做?
把tnavigator放在窗体外,并非不可见! 然后就是click啦!