unit4.~pas

来自「一系列DELPHI的控件如何使用的例子,例子有的比较简单,但是能详细的说明了控件」· ~PAS 代码 · 共 49 行

~PAS
49
字号
unit Unit4;

interface

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

type
  TForm1 = class(TForm)
    ADOCommand1: TADOCommand;
    DBGrid1: TDBGrid;
    DataSource1: TDataSource;
    ADOQuery1: TADOQuery;
    Panel1: TPanel;
    procedure DBGrid1DblClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.DBGrid1DblClick(Sender: TObject);
begin
    if messageDLG('确认是否删除',mtconfirmation,[mbyes,mbno],0)=mrno then
       exit;
     with ADOCommand1 do
     begin
     commandtext:='delete from student where sno=:sno';
     commandtype:=cmdtext;
     parameters.ParamByName('sno').Value:=DBGrid1.Fields[0].AsString;
     execute;
     end;
     with ADOQuery1 do
     begin
       close;
       open;
     end;
end;

end.

⌨️ 快捷键说明

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