就是说,我设计的一个控件的一个属性是STRING类型,要从另一个TSTRINGS类型的变量中选择,TSTRINGS类型的变量的内容由另一个属性维护,就象TNOTEBOOK中的ACTIVEPAGE一样内容由PAGES维护一样,我如何把TSTRING中的内容加到那个STRING的下拉框中来选,

解决方案 »

  1.   

    下拉表列的属性编辑器是枚举型的属性才有的。
    String的类型是没有的。
    而想不起来也不大合理呀,你的一个属性是String的,直接赋给它不是就了,用一个下拉列表能表达吗,有什么用处呢。
      

  2.   

    type
      TMyStringProperty = class(TStringProperty)
      public
        function GetAttributes: TPropertyAttributes; override;
        procedure GetValues(Proc: TGetStrProc); override;
      end;
    { TMyStringProperty }function TMyStringProperty.GetAttributes: TPropertyAttributes;
    begin
      Result := [paValueList, paSortList];
    end;
    procedure TMyStringProperty.GetValues(Proc: TGetStrProc);
    var
      I: Integer;
      StrList: TStringList;
    begin
      StrList := TYourComponent(GetComponent(0)).StringList;
      for I := 0 to StrList.Count - 1 do
        Proc(StrList[I]);
    end;
      

  3.   

    { TPageAccess }procedure TPageAccess.Clear;
    var
      I: Integer;
    begin
      for I := 0 to PageList.Count - 1 do
        TMyPage(PageList[I]).Free;
      PageList.Clear;
    end;constructor TPageAccess.Create(APageList: PList; ANotebook: TMyBook);
    begin
      inherited Create;
      PageList.Add(APageList);
      Notebook := ANotebook;
    end;procedure TPageAccess.Delete(Index: Integer);
    var
      Form: TCustomForm;
    begin
      TMyPage(PageList[Index]).Free;
      PageList.Delete(Index);
      NoteBook.PageIndex := 0;  if csDesigning in NoteBook.ComponentState then
      begin
        Form := GetParentForm(NoteBook);
        if (Form <> nil) and (Form.Designer <> nil) then
          Form.Designer.Modified;
      end;
    end;function TPageAccess.Get(Index: Integer): string;
    begin
      Result := TMyPage(PageList[Index]).Caption;
    end;function TPageAccess.GetCount: Integer;
    begin
      Result := PageList.Count;
    end;function TPageAccess.GetObject(Index: Integer): TObject;
    begin
      Result := PageList[Index];
    end;procedure TPageAccess.Insert(Index: Integer; const S: string);
    var
      Page: TMyPage;
      Form: TCustomForm;
    begin
      Page := TMyPage.Create(Notebook);
      with Page do
      begin
        Parent := Notebook;
        Caption := S;
      end;
      PageList.Insert(Index, Page);  NoteBook.PageIndex := Index;  if csDesigning in NoteBook.ComponentState then
      begin
        Form := GetParentForm(NoteBook);
        if (Form <> nil) and (Form.Designer <> nil) then
          Form.Designer.Modified;
      end;
    end;procedure TPageAccess.Move(CurIndex, NewIndex: Integer);
    var
      AObject: TObject;
    begin
      if CurIndex <> NewIndex then
      begin
        AObject := PageList[CurIndex];
        PageList[CurIndex] := PageList[NewIndex];
        PageList[NewIndex] := AObject;
      end;
    end;procedure TPageAccess.Put(Index: Integer; const S: string);
    begin
      TMyPage(PageList[Index]).Caption := S;
    end;procedure TPageAccess.SetUpdateState(Updating: Boolean);
    begin
    //  inherited;end;
      

  4.   

    怎么把属性编辑器的数据传回或者向属性编辑器传输数据呢。
      我做的属性编辑器时一个扩展TreeView的Items的编辑器,
      功能和TreeView的Items的编辑器功能一样,只是添加了一个属性。