Search code examples
delphicomponentsvirtualtreeviewtvirtualstringtree

Delphi: Component Build - Associate TVirtualStringTree


I'm building a new component and I would like to add one property where to associate a TVirtualStringTree object.

In the bellow picture I indicate and example from a TLabel object with the property FocusControl associated to a TEdit

enter image description here

If I do like this:

  TMyComponent = class(TComponent)
  private
    FVirtualStringTree: TVirtualStringTree;
  protected
    { Protected declarations }
  public
    constructor Create(AOwner: TComponent); override;
    destructor Destroy; override;
  published
    property VirtualStringTree: TVirtualStringTree read FVirtualStringTree write FVirtualStringTree;
  end;

I get an error like this: "Cannot load package .... It contains unit VirtualTrees.WorkerThread, which is also contained in package VirtualTreesR22.

Please an advise about how can I create this type of associations.


Solution

  • The problem is not the association, the problem is that you (indirectly) include code from TVirtualStringTree into the package, and another installed package already has that same unit.

    Since that other package is apparently the runtime package for TVirtualStringTree, you should simply reference that package from your package. Then it will not try to incorporate the unit, it will reference it from VirtualTreesR instead. This way, you avoid the conflict and all should be well:

    package Bla;
    
      ...
    
    requires
      VirtualTreesR,
      vcl,
      etc....