无论是开发什么样的程序,数据输入是不可缺少的。快速地生成一个美观的输入界面无疑会大大提高程序开发的效率。系统原有的控件,往往不尽人意。在delphi中......
附件:TDBPanel的源代码
unit DBPanel;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, dbctrls, stdctrls, db;
type
TDBPanel = class(TPanel)
private
{ Private declarations }
FLeft: Integer;
FTop: Integer;
maxTextLen: Integer;
maxLabelLen: Integer;
FScrollBox: TScrollBox;
{
滚动控件}
FLineHeight: Integer;
FClick: TNotifyEvent;
Editors: array of TDBComboBox; -$#@62;
具体进行编辑所用的数据控件数组,动态生成Labels: array of TLabel; -$#@62;
各字段的标题,动态生成OkButton: TButton; -$#@62;
最后增加的确定按钮,用于实现提交动作。
{
数据源}
FDataSource: TDataSource;
FColumns: Integer; -$#@62;
输入表格的列数
protected
{
Protected declarations }
procedure FreeEditors; -$#@62;
释放数据输入控件的内存
public
procedure CreateEditors;//(DS: TDataSource; ColCount: Integer);-$#@62;
创建各字段的数据输入控件constructor Create(AOwner: TComponent); override;
destructor Destroy; override;
procedure AKeyPress(Sender: TObject; var Key: Char);
procedure AKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
procedure ClearHits(ItemIndex: Integer);
procedure AddHits(ItemIndex: Integer; Hits: array of string);
function Editor(Index: Integer): TDBComboBox;
{
Public declarations }
published
property LeftLimit: Integer read FLeft write FLeft default 10;
property TopLimit: Integer read FTop write FTop default 10;
property EditorLen: Integer read maxTextLen write maxTextLen;
property LabelLen: Integer read maxLabelLen write maxLabelLen default 100;
property LineHeight: Integer read FLineHeight write FLineHeight default 15;
property OnOkClick: TNotifyEvent read FClick write FClick;
property DataSource: TDataSource read FDataSource write FDataSource;-$#@62;
数据源property Columns: In
查看本文来源