偶写的第一个控件,一个用选择代替输入的Edit控件

2008-04-09 04:21:11来源:互联网 阅读 ()

新老客户大回馈,云服务器低至5折


{***************************************************************}
{ }
{ Siow写的第一个控件 }
{ }
{用途:主要用于数据录入界面 }
{特点:用选择代替输入,减少人工录入时的低级错误 }
{版本:V1.1 }
{已知Bugs:1、在设计期如果数据源Active就无法编译 }
{ 2、ConnectionString编缉问题。加上ADOReg,DesignIntf后,}
{ 控件可安装却有好多引用单元无法编译,郁闷-_-! }
{联系方式:E-Mail:fuyushui@sohu.com }
{ QQ:1253366 }
{ }
{ }
{***************************************************************}


unit DBLookUpEdit;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Grids, DBGrids, StdCtrls, DB, ADODB;
//,ADOReg,DesignIntf,DesignEditors
type

{TDBLookUpEdit}

TDBLookUpEdit = class(TEdit)
private
FCreating: Boolean;
FKeyField: WideString;
FDBGrid : TDBGrid;
FADOQuery: TADOQuery;
FDataSource: TDataSource;
FOnEnter: TNotifyEvent;
FOnExit: TNotifyEvent;
FOnChange: TNotifyEvent;
//FOnClick: TNotiFyEvent;
//FOnDblClick:TNotifyEvent;
procedure CNCommand(var Message: TWMCommand);
message CN_COMMAND;
function GetActive: Boolean;
procedure SetActive(Value: Boolean);
function GetDataSource: TDataSource;
procedure SetDataSource(Value: TDataSource);
function GetConnectionString: WideString;
procedure SetConnectionString(const Value: WideString);
function GetConnection: TADOConnection;
procedure SetConnection(const Value: TADOConnection);
function GetSQL: TStrings;
procedure SetSQL(const Value: TStrings);
procedure SetRecText(FieldNo: integer);
procedure DoFDBGridMouseUp(Sender: TObject; Button: TMouseButton;Shift: TShiftState; X, Y: Integer);
procedure DoFDBGridKeyDown(Sender: TObject; var Key: Word;Shift: TShiftState);
protected
procedure SetParent(AParent: TWinControl); override;
procedure Notification(AComponent: TComponent; Operation: TOperation); override;
procedure CMVisiblechanged(var Message: TMessage);
message CM_VISIBLECHANGED;
procedure CMEnabledchanged(var Message: TMessage);
message CM_ENABLEDCHANGED;
procedure CMBidimodechanged(var Message: TMessage);
message CM_BIDIMODECHANGED;
procedure FDoEnter(Sender: TObject);
procedure FDoExit(Sender: TObject);
procedure KeyDown(var Key: Word; Shift: TShiftState); override;
procedure KeyPress(var Key: Char); override;
procedure KeyUp(var Key: Word; Shift: TShiftState); override;
procedure Loaded; override;
procedure CreateWnd; override;
public
constructor Create(AOwner: TComponent); override;
procedure SetBounds(ALeft: Integer; ATop: Integer; AWidth: Integer; AHeight: Integer); override;

published
//procedure Click;override;
property KeyFieldName:WideString read FKeyField write FKeyField;
procedure DblClick; override;
property OnEnter: TNotifyEvent read FOnEnter write FOnEnter;
property OnExit: TNotifyEvent read FOnExit write FOnExit;
property OnChange: TNotifyEvent read FOnChange write FOnChange;
//property OnClick: TNotifyEvent read FOnClick write FOnClick;
//property OnDblClick: TNotifyEvent read FOnDblClick write FOnDblClick;
//property DataSource: TDataSource read GetDataSource write SetDataSource;
property Active: Boolean read GetActive write SetActive default False;
property ConnectionString: WideString read GetConnectionString write SetConnectionString;
property Connection: TADOConnection read GetConnection write SetConnection;
property SQL: TStrings read GetSQL write SetSQL;
end;

procedure Register;

implementation

{ TDBLookUpEdit }

procedure Register;
begin
RegisterComponents(''''LD Controls'''', [TDBLookUpEdit]);
//RegisterPropertyEditor(TypeInfo(WideString), TDBLookUpEdit, ''''ConnectionString'''', TConnectionStringProperty);
end;

constructor TDBLookUpEdit.Create(AOwner: TComponent);
begin
inherited;
FDBGrid :=TDBGrid.Create(Self);
FADOQuery :=TADOQuery.Create(self);

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:编译原理的一个简单的枚举算法

下一篇:delphi7的新特性