解决了datatree的‘死节点’问题[2]

[入库:2006年2月23日] [更新:2007年3月24日]

本文简介:

        if  (left-1)> targe then
        begin
          if (stringlist.Strings[targe]='{')  then
              exit;
          for i:=left-1 to right do
              changeList.Add(stringlist.Strings[i]);
          for i:=targe to left-2 do
              changeList.Add(stringlist.Strings[i]);
          for i:=targe to right do
              stringlist.Strings[i]:= changeList.Strings[i-targe];
        end;
      end
      else
      begin
        if FocusNode.Index > TargetNode.Index then
        begin
          if (stringlist.Strings[TargetNode.Index]='{')  then
              exit;
          changeList.Add(stringlist.Strings[FocusNode.index]);
          for i:=TargetNode.Index to FocusNode.Index-1 do
              changeList.Add(stringlist.Strings[i]);
          for i:=TargetNode.Index to FocusNode.Index do
              stringlist.Strings[i]:= changeList.Strings[i-TargetNode.Index];
        end;

//行拖动问题   

     if FocusNode.Index < TargetNode.Index then
        begin
          if (LeftStr(stringlist.Strings[TargetNode.Index],5)='While') or (LeftStr(stringlist.Strings[TargetNode.Index],3)='for') then
              Exit;
          for i:=FocusNode.Index+1 to targetnode.Index do
              changeList.add(stringlist.Strings[i]);
          changeList.Add(stringlist.Strings[FocusNode.index]);
          for i:=FocusNode.Index to TargetNode.Index do
              stringlist.Strings[i]:= changeList.Strings[i-FocusNode.Index];
        end;
      end;
      changeList.Free;
      DataTree.EndUpdate;
      DataTree.Clear; //只加了这行代码就解决了!原理:重画了整个树,就不存在width cach的问题了
      self.DataTree.RootNodeCount:=stringlist.Count;
      DataTree.Refresh;
      Exit;
    end
    else if pnode2.typename = 'MobileUserAgent' then
    begin
      if targe > 0 then
        stringlist.Insert(targe, CreateUserAgentCode(pnode2.data))
      else
        stringlist.Append(CreateUserAgentCode(pnode2.data));
      self.DataTree.RootNodeCount:=stringlist.Count;
      DataTree.Refresh;
      Exit;
    end

//脚本拖动问题
    else
    begin
      if application.MessageBox('Are you sure to replace current script?', 'Message', MB_OKCANCEL) = IDCancel then
        exit;

      sql := 'Select texts from systemobjects where itemid=''' + pnode2.id + '''';
      currentdatabase.ExeuteSQlQurey(pnode2, sql, @GetScriptFromDB);
      Self.SetScript(pnode2.texts);
      Exit;
    end;
  end;
end;

本文关键:解决了datatree的‘死节点’问题
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top