为什么我在Form中发布的三个属性
myname
yourname
myColor
在Object Inspector中看不到呢?是Delphi的问题还是我程序写的不对?
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls,
Forms, Dialogs, ExtCtrls, StdCtrls, ComCtrls, Buttons;type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Edit1: TEdit;
BitBtn1: TBitBtn;
procedure Button1Click(Sender: TObject); private
Fmyname:string;
Fyourname:string;
FmyColor:Tcolor;
function Getmyname: string;
procedure Setmyname(value:string);
procedure Setcolor(value:Tcolor);
protected { Private declarations }
public { Public declarations }
published
property youname:string read Fyourname;
property myname:string read Getmyname write setmyname;
property myColor: TColor read FmyColor write SetColor default clBtnHighlight;
{ published declarations here } end;var
Form1: TForm1;implementation{$R *.dfm}
{$M+}{ TForm1 }function TForm1.Getmyname: string;
begin
Result := Fmyname;
end;procedure TForm1.Setcolor(value: Tcolor);
begin
if Value <> Color then
FmyColor := Value;
end;procedure TForm1.Setmyname(value: string);
begin
if Value <> myname then
Fmyname := Value;
end;procedure TForm1.Button1Click(Sender: TObject);
begin
form1.Fmyname:='myname_test';
edit1.Text:=myname;
end;end.
解决方案 »
- 当web网页刷新时,如何执行delphi写的activex控件的销毁函数?
- delphi用ado连接mysql数据库,往表里写中文数据时发生错误。怎么解决
- 怎样循环从数据库里读取记录
- 请教大侠!DELPHI可不可以读取TXT文本!
- ActionList
- WORD中图片大小控制问题
- 将一个TQuery的数据导出为Excel文件时,怎样控制复杂的表头结构?
- 请问怎么用dbEdit,dbImage等控件?
- 绝顶好的文章,不可不看,如果你还犹豫,那就当是进来拿分吧!
- 急急急!一个关于dblist和dbcombox的问题!
- ****问一问-------Delphi是不是很有前途的语言?**** 讨论有分?
- 我想显示数据库中的所有字段,但是我要用DISTINCT 刷掉其中重复的zch字段。
不过呢,也没关系,这并不影响你在程序中调用他们。
property youname:string read Fyourname;
只读的属性在属性面板上是看不到的
可以改成:
property youname:string read Fyourname write setyouname;procedure TForm1.setyouname(value:string);
begin
//什么也不干
end;
第二:也是主要原因,窗体的发布有些特殊
需要把TForm1发到包中编译注册才行
Delphi5和6有些不同,6的有点麻烦,所以这里告诉你Delphi6的
新建一个注册的单元
内容如下
unit MY_Form_Reg;interfaceuses
你的窗体单元, DesignIntf, DesignEditors;procedure Register;implementationprocedure Register;begin
RegisterCustomModule(你的窗体类名, TCustomModule);
end;end.新建一个包选中Require点击ADD。
添加Delphi目录下的bin目录中的designide.dcp文件。
然后编译安装。
最后在窗体上点击右键选“添加到仓库”添到一个仓库内比如“Form”
新建工程,选File|New|在你的仓库中选你添加的窗体。试试看
累死我了
佩服另外帮你补充一下
将下面多加一些单元
uses
你的窗体单元, DesignIntf, DesignEditors;
改写为:
你的窗体单元, Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, DesignIntf, DesignEditors, DB, DBTables, DBCtrls;很感谢又长了知识,谢谢!