demo.pas

来自「《Delphi 7经典问题解析》源代码____字符串汉字统计.rar《Delph」· PAS 代码 · 共 95 行

PAS
95
字号
unit demo;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, Grids, DBGrids, Buttons, DB, DBTables;

type
  TForm1 = class(TForm)
    DBGrid1: TDBGrid;
    ComboBox1: TComboBox;
    RadioGroup1: TRadioGroup;
    RadioButton1: TRadioButton;
    RadioButton2: TRadioButton;
    Edit1: TEdit;
    BitBtn1: TBitBtn;
    BitBtn2: TBitBtn;
    Query1: TQuery;
    Table1: TTable;
    DataSource1: TDataSource;
    Label1: TLabel;
    procedure FormActivate(Sender: TObject);
    procedure BitBtn2Click(Sender: TObject);
    procedure ComboBox1Click(Sender: TObject);
    procedure RadioButton2Click(Sender: TObject);
    procedure BitBtn1Click(Sender: TObject);
    procedure RadioButton1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormActivate(Sender: TObject);
begin
    Table1.DatabaseName:='dbdemos';
    Edit1.Text:='';
    ComboBox1.Text:='';
    Edit1.Enabled:=false;
    Datasource1.DataSet:=table1;
    Radiobutton1.Checked:=true;
    session.GetTableNames('dbdemos','*.db',false,false,ComboBox1.Items);
    Bitbtn1.Enabled:=false;
end;

procedure TForm1.BitBtn2Click(Sender: TObject);
begin
    close;
end;

procedure TForm1.ComboBox1Click(Sender: TObject);
begin
    Table1.active:=false;
    ComboBox1.Text:=ComboBox1.Items[ComboBox1.Itemindex];
    Table1.TableName:=ComboBox1.Text;
    Table1.TableType:=ttParadox;
    Table1.active:=true;
end;

procedure TForm1.RadioButton2Click(Sender: TObject);
begin
    if RadioButton2.Checked then
    begin
        Edit1.enabled:=true;
        Bitbtn1.Enabled:=true;
        ComboBox1.Enabled:=false;
    end;
end;

procedure TForm1.BitBtn1Click(Sender: TObject);
begin
    DataSource1.DataSet:=query1;
    query1.DatabaseName:='dbdemos';
    query1.SQL.Clear;
    query1.SQL.add(Edit1.Text);
    query1.open;
end;

procedure TForm1.RadioButton1Click(Sender: TObject);
begin
    ComboBox1.Enabled:=true;
    Bitbtn1.Enabled:=false;
    Edit1.Enabled:=false;
end;

end.

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?