自定义控件问题(50分)

  • 主题发起人 主题发起人 Sohe
  • 开始时间 开始时间
S

Sohe

Unregistered / Unconfirmed
GUEST, unregistred user!
我自已做了一个控件,就是一个MastEdit和Edit控件组合在一起(这两个控件放在一个Panel上),因为要传递一些参数,所以不能用Frame, 可是把这个控件拖到表单上时,只
能看到和修改Panel的属性,而MastEdit和Edit的属性都看不到。
哪位能帮我改一下,能让MastEdit和Edit的属性都能显示以便修改。

unit CodeNamePanel;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Controls, StdCtrls, Mask, ExtCtrls;

type
TpanCodeName = Class(TPanel)
private
FSQL: String;
FTitle: String;
FField: String;
FCode: TMaskEdit;
FName: TEdit;
procedure SetCode(Value: TMaskEdit);
procedure SetName(Value: TEdit);
protected
property EditCode: TMaskEdit read FCode write SetCode;
property EditName: TEdit read FName write SetName;
public
constructor Create(AOwner: TComponent); override;
destructor Destroy;
published
//
end;

procedure Register;

implementation

constructor TPanCodeName.Create(AOwner: TComponent);
var
FCode: TMaskEdit;
FName: TEdit;
begin
inherited Create(AOwner);
FCode := TMaskEdit.Create(nil);
FCode.Parent := self;
FCode.Width := 65;
FName := TEdit.Create(nil);
FName.Parent := self;
FName.Left := 65;
Self.BevelOuter := bvNone;
Self.Caption := '';
Self.Height := Self.Controls[0].Height + 2;
Self.width := Self.Controls[0].Width + Self.Controls[1].Width;
end;

destructor TPanCodeName.Destroy;
begin
FName.Free;
FCode.Free;
inherited Destroy;
end;

procedure TPanCodeName.SetCode(Value: TMaskEdit);
begin
EditCode.Assign(Value);
end;

procedure TPanCodeName.SetName(Value: TEdit);
begin
EditName.Assign(Value);
end;

procedure Register;
begin
RegisterComponents('XhLib', [TPanCodeName]);
end;

end.
 
写的不对!
procedure SetCode(Value: TMaskEdit);
procedure SetName(Value: TEdit);
我觉得根本就没有用!
 
published
property EditCode: TMaskEdit read FCode write SetCode;
property EditName: TEdit read FName write SetName;
 
还是不行
而且MastEdit和Edit不能拖动。

哪位高手有没有做过这种组合控件
 
我用Frame做了一个,基本上可以达到我的要求,把这个Frame加到控件面板上,拖一个到表单上,可是自已增加的属性不能显示的Properties面板上,怎么改才能让新增的属性能出现在Properties面板上。

unit MyFrame;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;

type
TMyFrame = class(TFrame)
MaskEdit1: TMaskEdit;
Edit1: TEdit;
private
{ Private declarations }
FSQL: String;
procedure SetSQL(v: String);
public
{ Public declarations }
published
property SQL: String read FSQL write SetSQL;
end;

procedure Register;

implementation

{$R *.dfm}

procedure TMyFrame.SetSQL(v: String);
begin
FSQL := v;
end;

procedure Register;
begin
RegisterComponents('XhLib', [TMyFrame]);
end;

end.
 
问题已解决
现在有一个问题,能不能让Frame的属性在Properties面板上只显示我想要修改的属性,其它的属性不显示。
 

Similar threads

后退
顶部