找传奇、传世资源到传世资源站!

DBGridEh实现下拉列表(源码)

8.5玩家评分(1人评分)
下载后可评
介绍 评论 失效链接反馈

【例子介绍】dbgrideh实现下拉列表

【相关图片】

from clipboard

【源码结构】

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, DBGridEhGrouping, ToolCtrlsEh, DBGridEhToolCtrls, DynVarsEh, Data.DB,
  Data.Win.ADODB, EhLibVCL, GridsEh, DBAxisGridsEh, DBGridEh, Datasnap.DBClient;

type
  TForm1 = class(TForm)
    grd1 :TDBGridEh;
    ds1 :TDataSource;
    cds1 :TClientDataSet;
    cds1Goods :TStringField;
    cds1Qutity :TIntegerField;
    qry1 :TADOQuery;
    procedure FormCreate(Sender :TObject);
    procedure grd1Columns0UpdateData(Sender: TObject; var Text: string; var Value: Variant; var UseText, Handled: Boolean);
    private
    c: TColumnEh;
      { Private declarations }
    public
      { Public declarations }
  end;

var
  Form1 :TForm1;

implementation

uses
  MidasLib;

{$R *.dfm}


procedure TForm1.FormCreate(Sender :TObject);


begin
  cds1.CreateDataSet;

  c := grd1.Columns[0];
  qry1.Open;
  qry1.First;
  while qry1.Eof = False do begin

    c.PickList.Add(qry1.FieldByName('goods').AsString);
    qry1.Next;
  end;

end;

procedure TForm1.grd1Columns0UpdateData(Sender: TObject; var Text: string; var Value: Variant; var UseText, Handled:
    Boolean);
begin
  if c.PickList.IndexOf(Text)=-1 then
    c.PickList.Add(Text);
end;

end.

评论

发表评论必须先登陆, 您可以 登陆 或者 注册新账号 !


在线咨询: 问题反馈
客服QQ:174666394

有问题请留言,看到后及时答复