我在开发控件的属性编辑器的时候,遇到一个问题,如果在form上放置多个相同的控件,在
变化一个控件时,其余的几个也同样跟着变化,不能独立设置!请各位指点!
具体的实例如下:
unit ssTest;interfaceuses
Windows, Messages, SysUtils, Classes,DesignEditors,DesignIntf;
type TCataProperty = class(TPropertyEditor)
public
function GetAttributes:TPropertyAttributes;override;
function GetValue:string;override;
procedure SetValue(const Value:String);override;
procedure GetValues (proc:TGetStrProc);override;
end;
type
TssTest = class(Tcomponent)
private
{ Private declarations }
FCataProperty : string;
function GetCatlaog:string;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property Catalog:string read GetCatlaog write FCataProperty stored true;
end;procedure Register;implementation
var
CName:string;
procedure Register;
begin
RegisterComponents('HDC4', [TssTest]);
RegisterPropertyEditor(TypeInfo(string),TssTest,'Catalog',TCataProperty);
end;{ TCataProperty }function TCataProperty.GetAttributes: TPropertyAttributes;
begin
result := [paValueList];
end;function TCataProperty.GetValue: string;
begin
result := CName;
end;procedure TCataProperty.GetValues(proc: TGetStrProc);
var
i:integer; st:TStringList;
begin
//st := TStringList.Create;
//for i:=0 to 4 do
// st.Add(inttostr(i));
for i:=0 to 4 do
begin
proc (inttostr(i));
end;end;procedure TCataProperty.SetValue(const Value:String);
begin
CName := Value;end;{ TssTest }function TssTest.GetCatlaog: string;
begin
result := CName;
FCataProperty:= CName;
end;end.
变化一个控件时,其余的几个也同样跟着变化,不能独立设置!请各位指点!
具体的实例如下:
unit ssTest;interfaceuses
Windows, Messages, SysUtils, Classes,DesignEditors,DesignIntf;
type TCataProperty = class(TPropertyEditor)
public
function GetAttributes:TPropertyAttributes;override;
function GetValue:string;override;
procedure SetValue(const Value:String);override;
procedure GetValues (proc:TGetStrProc);override;
end;
type
TssTest = class(Tcomponent)
private
{ Private declarations }
FCataProperty : string;
function GetCatlaog:string;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property Catalog:string read GetCatlaog write FCataProperty stored true;
end;procedure Register;implementation
var
CName:string;
procedure Register;
begin
RegisterComponents('HDC4', [TssTest]);
RegisterPropertyEditor(TypeInfo(string),TssTest,'Catalog',TCataProperty);
end;{ TCataProperty }function TCataProperty.GetAttributes: TPropertyAttributes;
begin
result := [paValueList];
end;function TCataProperty.GetValue: string;
begin
result := CName;
end;procedure TCataProperty.GetValues(proc: TGetStrProc);
var
i:integer; st:TStringList;
begin
//st := TStringList.Create;
//for i:=0 to 4 do
// st.Add(inttostr(i));
for i:=0 to 4 do
begin
proc (inttostr(i));
end;end;procedure TCataProperty.SetValue(const Value:String);
begin
CName := Value;end;{ TssTest }function TssTest.GetCatlaog: string;
begin
result := CName;
FCataProperty:= CName;
end;end.
解决方案 »
- 庆祝CSDN挂后重生,饭后结帖
- 能在一个 DBGrid 中显示 两个不同 数据库中 的两个表中的 内容?
- 高分求解半透明窗体(UpdateLayeredWindow)时子控件显示问题!
- 有没有郑州的Delphi程序员?
- DELPHI如何向远程的已经存在的ASP页面,用POST或GET方式提交参数呢?我可以提交,不过。有小问题。盼高人回复
- 24針打印機可否通過程序控制打印出9針打印的效果
- Delphi7 对 ShockWaveFlash 的应用报错
- 批量更新问题
- 请问哪儿有票据打印的控件
- 怎样增加我的可用分?我实在是无分可给了....
- 请问一下“无纸化办公”是一个什么样的观念,对程序员有什么要求?
- 怎么来实现这样的功能?
help me!
Windows, Messages, SysUtils, Classes, DesignEditors, DesignIntf;type
TCataProperty = class(TPropertyEditor)
public
function GetAttributes: TPropertyAttributes; override;
function GetValue: string; override;
procedure SetValue(const Value: string); override;
procedure GetValues(Proc: TGetStrProc); override;
end;type
TssTest = class(TComponent)
private
{ Private declarations }
FCatlaog: string;
function GetCatlaog: string;
protected
{ Protected declarations }
public
{ Public declarations }
published
{ Published declarations }
property Catalog: string read GetCatlaog write FCatlaog stored True;
end;procedure Register;implementationprocedure Register;
begin
RegisterComponents('HDC4', [TssTest]);
RegisterPropertyEditor(TypeInfo(string), TssTest, 'Catalog', TCataProperty);
end;{ TCataProperty }function TCataProperty.GetAttributes: TPropertyAttributes;
begin
Result := [paValueList];
end;function TCataProperty.GetValue: string;
begin
Result := GetStrValue;
end;procedure TCataProperty.GetValues(Proc: TGetStrProc);
var
I: Integer;
begin
for I := 0 to 4 do if Assigned(Proc) then Proc(IntToStr(I));
end;procedure TCataProperty.SetValue(const Value: string);
begin
SetStrValue(Value);
end;{ TssTest }function TssTest.GetCatlaog: string;
begin
Result := FCatlaog;
end;end.
begin
result := CName; //这一条语句决定了,全部的值都相对
FCataProperty:= CName;
end;也不做太多的说明,因为事实上,我也很上很少玩属性编辑器这类的程序~~嘻嘻嘻 伴水 :) 到此一灌 嘻嘻嘻嘻