![]() |
|
#2
|
||||
|
||||
![]() Вот вам пример, но лучше делать не через чекбокс, а радиогрупп.
Код:
unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, DB, Grids, DBGrids, DBClient; type TForm1 = class(TForm) ClientDataSet1: TClientDataSet; ClientDataSet1Employee: TStringField; ClientDataSet1Dismiss: TBooleanField; DBGrid1: TDBGrid; DataSource1: TDataSource; CheckBox1: TCheckBox; procedure CheckBox1Click(Sender: TObject); end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.CheckBox1Click(Sender: TObject); begin ClientDataSet1.Filtered := False; ClientDataSet1.Filter := Format('Dismiss=%d',[Integer(CheckBox1.Checked)]); ClientDataSet1.Filtered := True; end; end. Код:
object Form1: TForm1 Left = 369 Top = 113 Width = 870 Height = 640 Caption = 'Form1' Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -11 Font.Name = 'Tahoma' Font.Style = [] OldCreateOrder = False PixelsPerInch = 96 TextHeight = 13 object DBGrid1: TDBGrid Left = 16 Top = 104 Width = 393 Height = 217 DataSource = DataSource1 TabOrder = 0 TitleFont.Charset = DEFAULT_CHARSET TitleFont.Color = clWindowText TitleFont.Height = -11 TitleFont.Name = 'Tahoma' TitleFont.Style = [] Columns = < item Expanded = False FieldName = 'Employee' Width = 200 Visible = True end item Expanded = False FieldName = 'Dismiss' Visible = True end> end object CheckBox1: TCheckBox Left = 24 Top = 80 Width = 97 Height = 17 Caption = 'Уволенные' TabOrder = 1 OnClick = CheckBox1Click end object ClientDataSet1: TClientDataSet Active = True Aggregates = <> Params = <> Left = 32 Top = 16 Data = { 470000009619E0BD010000001800000002000000000003000000470008456D70 6C6F7965650100490000000100055749445448020002006400074469736D6973 7302000300000000000000} object ClientDataSet1Employee: TStringField FieldName = 'Employee' Size = 100 end object ClientDataSet1Dismiss: TBooleanField FieldName = 'Dismiss' end end object DataSource1: TDataSource DataSet = ClientDataSet1 Left = 64 Top = 16 end end Жизнь такова какова она есть и больше никакова. Помогаю за спасибо. |