标签:
DbgridEh 对应数据集ADOTable1,其中有个字段 部门编码,另外增加查找字段比如 部门名称
ADOTable2对应查找数据集,包含 部门编码和 部门名称字段。
ADOTable1 打开后,再运行
ADOTable2.Close;
ADOTable2.Open;
后记录不是在第一个,需要再
ADOTable2.First;
否则 ADOTable2.Eof 为 true
如果ADOTable1对应的是普通的DBGRID,则不需要 ADOTable2.First;
奇怪了。
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, DBGridEhGrouping, ToolCtrlsEh, DBGridEhToolCtrls, DynVarsEh, DB, ADODB, EhLibVCL, GridsEh, DBAxisGridsEh, DBGridEh, StdCtrls, Grids, DBGrids; type TForm1 = class(TForm) DBGridEh1: TDBGridEh; ADOConnection1: TADOConnection; ADOTable1: TADOTable; ADOTable2: TADOTable; DataSource1: TDataSource; DataSource2: TDataSource; ADOTable1name: TWideStringField; ADOTable1bmid: TIntegerField; ADOTable1bmname: TStringField; Button1: TButton; DBGrid1: TDBGrid; DBGrid2: TDBGrid; procedure FormCreate(Sender: TObject); procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin ADOTable2.Close; ADOTable2.Open; if ADOTable2.Eof then ShowMessage(‘Eof‘) else ShowMessage(‘Not Eof‘) end; procedure TForm1.FormCreate(Sender: TObject); begin ADOTable1.Open; end; end.
object Form1: TForm1 Left = 0 Top = 0 Caption = ‘Form1‘ ClientHeight = 281 ClientWidth = 713 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = ‘Tahoma‘ Font.Style = [] OldCreateOrder = False OnCreate = FormCreate PixelsPerInch = 96 TextHeight = 13 object DBGridEh1: TDBGridEh Left = 8 Top = 8 Width = 297 Height = 105 DataSource = DataSource1 DynProps = <> IndicatorOptions = [gioShowRowIndicatorEh] TabOrder = 0 object RowDetailData: TRowDetailPanelControlEh end end object Button1: TButton Left = 432 Top = 248 Width = 75 Height = 25 Caption = ‘Button1‘ TabOrder = 1 OnClick = Button1Click end object DBGrid1: TDBGrid Left = 8 Top = 152 Width = 320 Height = 120 DataSource = DataSource2 TabOrder = 2 TitleFont.Charset = DEFAULT_CHARSET TitleFont.Color = clWindowText TitleFont.Height = -11 TitleFont.Name = ‘Tahoma‘ TitleFont.Style = [] end object DBGrid2: TDBGrid Left = 344 Top = 8 Width = 361 Height = 105 DataSource = DataSource1 TabOrder = 3 TitleFont.Charset = DEFAULT_CHARSET TitleFont.Color = clWindowText TitleFont.Height = -11 TitleFont.Name = ‘Tahoma‘ TitleFont.Style = [] end object ADOConnection1: TADOConnection Connected = True ConnectionString = ‘Provider=Microsoft.Jet.OLEDB.4.0;Data Source=G:\XE Projects\Ehli‘ + ‘b\Debug\Win32\db1.mdb;Persist Security Info=False‘ LoginPrompt = False Mode = cmShareDenyNone Provider = ‘Microsoft.Jet.OLEDB.4.0‘ Left = 456 Top = 24 end object ADOTable1: TADOTable Connection = ADOConnection1 CursorType = ctStatic TableName = ‘person‘ Left = 432 Top = 80 object ADOTable1name: TWideStringField FieldName = ‘name‘ Size = 50 end object ADOTable1bmid: TIntegerField FieldName = ‘bmid‘ end object ADOTable1bmname: TStringField FieldKind = fkLookup FieldName = ‘bmname‘ LookupDataSet = ADOTable2 LookupKeyFields = ‘bmid‘ LookupResultField = ‘bmname‘ KeyFields = ‘bmid‘ Lookup = True end end object ADOTable2: TADOTable Connection = ADOConnection1 CursorType = ctStatic TableName = ‘bm‘ Left = 424 Top = 176 end object DataSource1: TDataSource DataSet = ADOTable1 Left = 496 Top = 80 end object DataSource2: TDataSource DataSet = ADOTable2 Left = 496 Top = 176 end end
EhLib 的 DbgridEh 影响 其他数据集的Open方法
标签:
原文地址:http://www.cnblogs.com/CodeGear/p/4308192.html