程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> TClientDataSet[17]: StatusFilter

TClientDataSet[17]: StatusFilter

編輯:Delphi

測試圖:

TClientDataSet[17]: StatusFilter

  測試代碼:

unit Unit1; 
 
interface 
 
uses 
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
 Dialogs, StdCtrls, CheckLst, Grids, DBGrids, DB, DBClIEnt; 
 
type 
 TForm1 = class(TForm) 
  ClientDataSet1: TClIEntDataSet; 
  DataSource1: TDataSource; 
  DBGrid1: TDBGrid; 
  ClientDataSet2: TClIEntDataSet; 
  DataSource2: TDataSource; 
  DBGrid2: TDBGrid; 
  Button1: TButton; 
  Button2: TButton; 
  Button3: TButton; 
  Button4: TButton; 
  CheckListBox1: TCheckListBox; 
  procedure Button4Click(Sender: TObject); 
  procedure Button2Click(Sender: TObject); 
  procedure Button3Click(Sender: TObject); 
  procedure FormCreate(Sender: TObject); 
  procedure Button1Click(Sender: TObject); 
  procedure CheckListBox1Click(Sender: TObject); 
 end; 
 
var 
 Form1: TForm1; 
 
implementation 
 
{$R *.dfm} 
 
procedure TForm1.FormCreate(Sender: TObject); 
begin 
 DBGrid1.DataSource := DataSource1; 
 DataSource1.DataSet := ClIEntDataSet1; 
 
 DBGrid2.DataSource := DataSource2; 
 DataSource2.DataSet := ClIEntDataSet2; 
 
 with ClIEntDataSet1 do begin 
  FIEldDefs.Add('Text', ftString, 12); 
  FIEldDefs.Add('Num', ftInteger); 
  CreateDataSet; 
  AppendRecord(['XXX', 111]); 
  AppendRecord(['YYY', 222]); 
  AppendRecord(['ZZZ', 333]); 
 end; 
 ClientDataSet2.CloneCursor(ClIEntDataSet1, False); 
 
 CheckListBox1.Items.CommaText := 'usUnmodified, usModifIEd, usInserted, usDeleted'; 
end; 
 
procedure TForm1.CheckListBox1Click(Sender: TObject); 
var 
 i: Integer; 
begin 
 ClIEntDataSet2.StatusFilter := []; 
 for i := 0 to CheckListBox1.Count - 1 do 
 begin 
  if CheckListBox1.Checked[i] then 
   ClientDataSet2.StatusFilter := ClIEntDataSet1.StatusFilter + [TUpdateStatus(i)] 
 end; 
end; 
 
procedure TForm1.Button1Click(Sender: TObject); 
begin 
 ClIEntDataSet1.Append; 
end; 
 
procedure TForm1.Button2Click(Sender: TObject); 
begin 
 ClIEntDataSet1.Delete; 
end; 
 
procedure TForm1.Button4Click(Sender: TObject); 
begin 
 ClIEntDataSet1.MergeChangeLog; 
end; 
 
procedure TForm1.Button3Click(Sender: TObject); 
begin 
 ClIEntDataSet1.UndoLastChange(True); 
end; 
 
end. 

 測試窗體:

object Form1: TForm1 
 Left = 0 
 Top = 0 
 Caption = 'Form1' 
 ClIEntHeight = 231 
 ClIEntWidth = 496 
 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 ClientDataSet1: TClIEntDataSet 
  Aggregates = <> 
  Params = <> 
  Left = 64 
  Top = 64 
 end 
 object DataSource1: TDataSource 
  DataSet = ClIEntDataSet1 
  Left = 64 
  Top = 120 
 end 
 object DBGrid1: TDBGrid 
  Left = 0 
  Top = 0 
  Width = 193 
  Height = 231 
  Align = alLeft 
  DataSource = DataSource1 
  TabOrder = 0 
  TitleFont.Charset = DEFAULT_CHARSET 
  TitleFont.Color = clWindowText 
  TitleFont.Height = -11 
  TitleFont.Name = 'Tahoma' 
  TitleFont.Style = [] 
 end 
 object ClientDataSet2: TClIEntDataSet 
  Aggregates = <> 
  Params = <> 
  Left = 344 
  Top = 80 
 end 
 object DataSource2: TDataSource 
  Left = 344 
  Top = 136 
 end 
 object DBGrid2: TDBGrid 
  Left = 302 
  Top = 0 
  Width = 194 
  Height = 231 
  Align = alRight 
  TabOrder = 5 
  TitleFont.Charset = DEFAULT_CHARSET 
  TitleFont.Color = clWindowText 
  TitleFont.Height = -11 
  TitleFont.Name = 'Tahoma' 
  TitleFont.Style = [] 
 end 
 object Button1: TButton 
  Left = 199 
  Top = 8 
  Width = 97 
  Height = 25 
  Caption = 'Append' 
  TabOrder = 4 
  OnClick = Button1Click 
 end 
 object Button2: TButton 
  Left = 199 
  Top = 39 
  Width = 97 
  Height = 25 
  Caption = 'Delete' 
  TabOrder = 2 
  OnClick = Button2Click 
 end 
 object Button3: TButton 
  Left = 199 
  Top = 78 
  Width = 97 
  Height = 25 
  Caption = 'UndoLastChange' 
  TabOrder = 3 
  OnClick = Button3Click 
 end 
 object Button4: TButton 
  Left = 199 
  Top = 109 
  Width = 97 
  Height = 25 
  Caption = 'MergeChangeLog' 
  TabOrder = 1 
  OnClick = Button4Click 
 end 
 object CheckListBox1: TCheckListBox 
  Left = 199 
  Top = 152 
  Width = 97 
  Height = 70 
  ItemHeight = 13 
  TabOrder = 6 
  OnClick = CheckListBox1Click 
 end 
end 



  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved