L
lovefox
Unregistered / Unconfirmed
GUEST, unregistred user!
我是delphi初学者,我想做一个Edit和Listbox结合的组件。现在,组件中的FHelpIndex
无法在ListBox中显示。如何解决。
代码如下:
unit LBHelp;
interface
uses
Windows, Buttons, Messages, ExtCtrls, SysUtils, Classes, Graphics,Controls, Forms, Dialogs,StdCtrls;
type
TLBHelp = class(TCustomControl)
private
{ Private declarations }
FLabel:TLabel;
FEdit:TEdit;
FButton:TButton;
FHelpIndex:TStrings; // 搜索的序列,用户定义
FListBox:TListBox;//显示要搜索的所以内容
procedure SetHelpIndex(Value:TStrings);
protected
{ Protected declarations }
public
{ Public declarations }
constructor create(AOwner:TComponent);override;
Destructor Destroy; Override;
published
{ Published declarations }
property HelpIndex:TStrings read FHelpIndex write SetHelpIndex;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Lovefox', [TLBHelp]);
end;
constructor TLBHelp.create(AOwner:TComponent);
const
Gap=5;
begin
inherited Create(AOwner);
Width:=210;
Height:=233;
FLabel:=TLabel.create(self);
FLabel.parent:=self;
FLabel.height:=20;
FLabel.width:=210;
FLabel.caption:='Edit和ListBox结合的组件';
FLabel.top:=Gap;
FLabel.left:=Gap;
FEdit:=TEdit.create(self);
FEdit.parent:=self;
FEdit.height:=20;
FEdit.Width:=150;
FEdit.top:=FLabel.Top + FLabel.Height + Gap;
FEdit.left:=Gap;
FButton:=TButton.create(self);
FButton.parent:=self;
FButton.Caption:='搜索';
FButton.height:=20;
FButton.Width:=40;
FButton.top:=FEdit.Top;
FButton.left:=FEdit.left + FEdit.width + Gap;
FHelpIndex:=TStringList.Create;
FListBox:=TListBox.create(self);
FListBox.parent:=self;
FListBox.height:=200;
FListBox.width:=200;
FListBox.top:=FEdit.top + FEdit.height + Gap;
FListBox.left:=Gap;
end;
Destructor TLBHelp.Destroy;
begin
FLabel.free;
FEdit.free;
FButton.free;
FListBox.free;
inherited destroy;
end;
procedure TLBHelp.SetHelpIndex(value:TStrings);
begin
FHelpIndex.assign(value);
end;
end.
无法在ListBox中显示。如何解决。
代码如下:
unit LBHelp;
interface
uses
Windows, Buttons, Messages, ExtCtrls, SysUtils, Classes, Graphics,Controls, Forms, Dialogs,StdCtrls;
type
TLBHelp = class(TCustomControl)
private
{ Private declarations }
FLabel:TLabel;
FEdit:TEdit;
FButton:TButton;
FHelpIndex:TStrings; // 搜索的序列,用户定义
FListBox:TListBox;//显示要搜索的所以内容
procedure SetHelpIndex(Value:TStrings);
protected
{ Protected declarations }
public
{ Public declarations }
constructor create(AOwner:TComponent);override;
Destructor Destroy; Override;
published
{ Published declarations }
property HelpIndex:TStrings read FHelpIndex write SetHelpIndex;
end;
procedure Register;
implementation
procedure Register;
begin
RegisterComponents('Lovefox', [TLBHelp]);
end;
constructor TLBHelp.create(AOwner:TComponent);
const
Gap=5;
begin
inherited Create(AOwner);
Width:=210;
Height:=233;
FLabel:=TLabel.create(self);
FLabel.parent:=self;
FLabel.height:=20;
FLabel.width:=210;
FLabel.caption:='Edit和ListBox结合的组件';
FLabel.top:=Gap;
FLabel.left:=Gap;
FEdit:=TEdit.create(self);
FEdit.parent:=self;
FEdit.height:=20;
FEdit.Width:=150;
FEdit.top:=FLabel.Top + FLabel.Height + Gap;
FEdit.left:=Gap;
FButton:=TButton.create(self);
FButton.parent:=self;
FButton.Caption:='搜索';
FButton.height:=20;
FButton.Width:=40;
FButton.top:=FEdit.Top;
FButton.left:=FEdit.left + FEdit.width + Gap;
FHelpIndex:=TStringList.Create;
FListBox:=TListBox.create(self);
FListBox.parent:=self;
FListBox.height:=200;
FListBox.width:=200;
FListBox.top:=FEdit.top + FEdit.height + Gap;
FListBox.left:=Gap;
end;
Destructor TLBHelp.Destroy;
begin
FLabel.free;
FEdit.free;
FButton.free;
FListBox.free;
inherited destroy;
end;
procedure TLBHelp.SetHelpIndex(value:TStrings);
begin
FHelpIndex.assign(value);
end;
end.