论是开发什么样的程序,数据输入是不可缺少的。快速地生成一个美观的输入界面无疑会大大提高程序开发的效率。
Published declarations }
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents("Additional", [TDBPanel]);
end;
{ 为第I字段增加提示信息的方法}
procedure TDBPanel.AddHits(ItemIndex: Integer; Hits: array of string);
var
m,n,i: Integer;
begin
n := Length(Editors);
m := Length(Hits);
if ItemIndex$#@60;n then begin
for i:=0 to m-1 do Editors[ItemIndex].Items.Add(Hits[i]);
end;
end;
procedure TDBPanel.AKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
if (Sender is TDBComboBox) then begin
case Key of
VK_Next: (Sender as TDBComboBox).DataSource.DataSet.Next;
VK_PRIOR: (Sender as TDBComboBox).DataSource.DataSet.Prior;
end;
end;
end;
procedure TDBPanel.AKeyPress(Sender: TObject; var Key: Char);
begin
if (Sender is TDBComboBox) then begin
if Key=#13 then (Owner as TForm).Perform(WM_NEXTDLGCTL, 0, 0);
end;
end;
procedure TDBPanel.ClearHits(ItemIndex: Integer);
var
n: Integer;
begin
n := Length(Editors);
if ItemIndex$#@60;n then Editors[ItemIndex].Items.Clear;
end;
constructor TDBPanel.Create(AOwner: TComponent);
begin
Inherited Create(AOWner);
FLeft :=10;
FTop := 10;
maxTextLen := 100;
maxLabelLen := 100;
FLineHeight := 15;
end;