最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

delphi - Why cant I assign a value of nil to the fLastChild member of VirtualNode PvirtualNode - Stack Overflow

programmeradmin2浏览0评论

How to successfully assign nil to the property Lastchild below?

I try to assign 'nil' for instance to the fields fParent,fPrevSibling and fNextSibling by

----VirtualTree.Types-----

property PrevSibling: PVirtualNode read fPrevSibling    {Maths added: write }write fPrevSibling;
property NextSibling: PVirtualNode read fNextSibling    {Maths added: write }write fNextSibling;
property LastChild:   PVirtualNode read fLastChild      {Maths added: write }write fLastChild;  

The 'write' is added by me to succeed with assigning, but I get this error

MyCode:

procedure TfrmMonitor.DeleteChildren(aNode: PVirtualNode; aUpdateAlgos: Boolean = True);
var
  Run: PVirtualNode;
  Mark: PVirtualNode;
begin
  if Assigned(aNode) and (aNode.ChildCount > 0) then       //has child
  begin
    Run := aNode.LastChild;
    while Assigned(Run) do                               //last child
    begin
      Mark := Run;                                       //mark is last child
      Run := Run.PrevSibling;                            //run is first sibling
      if Assigned(Run) then
        Run.NextSibling := nil;    // Error cant assign to read only  property
      DeleteNode(Mark, aUpdateAlgos);
    end;
    aNode.FirstChild := nil;
    aNode.LastChild  := nil;        // Error cant assign to read only  property
  end;
end;

发布评论

评论列表(0)

  1. 暂无评论