// ClientDataSet1.Filter:='trim(optype)=''购入''';
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, DB, Grids, DBGrids, DBClient, StdCtrls;
type
TForm1 = class(TForm)
ClientDataSet1: TClientDataSet;
DBGrid1: TDBGrid;
DataSource1: TDataSource;
ClientDataSet1optype: TStringField;
Button1: TButton;
Button2: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
ClientDataSet1.CreateDataSet;
ClientDataSet1.AppendRecord(['郝峰鸽']);
ClientDataSet1.AppendRecord(['购入']);
ClientDataSet1.AppendRecord([' 购入']);
ClientDataSet1.AppendRecord([' 购入 ']);
ClientDataSet1.AppendRecord([' 购入 ']);
ClientDataSet1.AppendRecord([' 购入']);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
ClientDataSet1.Filter:='optype=''购入''';
ClientDataSet1.Filtered:=true;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
ClientDataSet1.Filter:='trim(optype)=''购入''';
ClientDataSet1.Filtered:=true;
end;
end.
object Form1: TForm1
Left = 192
Top = 107
Width = 544
Height = 375
Caption = 'Form1'
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -11
Font.Name = 'MS Sans Serif'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
PixelsPerInch = 96
TextHeight = 13
object DBGrid1: TDBGrid
Left = 0
Top = 0
Width = 145
Height = 348
Align = alLeft
DataSource = DataSource1
TabOrder = 0
TitleFont.Charset = DEFAULT_CHARSET
TitleFont.Color = clWindowText
TitleFont.Height = -11
TitleFont.Name = 'MS Sans Serif'
TitleFont.Style = []
end
object Button1: TButton
Left = 168
Top = 16
Width = 329
Height = 25
Caption = 'ClientDataSet1.Filter:=''optype=''''购入'''''';'
TabOrder = 1
OnClick = Button1Click
end
object Button2: TButton
Left = 168
Top = 48
Width = 329
Height = 25
Caption = ' ClientDataSet1.Filter:=''trim(optype)=''''购入'''''';'
TabOrder = 2
OnClick = Button2Click
end
object ClientDataSet1: TClientDataSet
Aggregates = <>
Params = <>
Left = 40
Top = 32
object ClientDataSet1optype: TStringField
FieldName = 'optype'
Size = 30
end
end
object DataSource1: TDataSource
DataSet = ClientDataSet1
Left = 104
Top = 88
end
end