我在开发控件的属性编辑器的时候,遇到一个问题,如果在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.

解决方案 »

  1.   

    难道没人能够解决这个问题?
    help me!
      

  2.   

    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 }
        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.
      

  3.   

    属性编辑器和你的元件不要发生交互~~function TssTest.GetCatlaog: string;
    begin
        result := CName; //这一条语句决定了,全部的值都相对
        FCataProperty:= CName;
    end;也不做太多的说明,因为事实上,我也很上很少玩属性编辑器这类的程序~~嘻嘻嘻 伴水 :) 到此一灌 嘻嘻嘻嘻