以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  发现一个代码应用速度问题  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=30200)

--  作者:e-png
--  发布时间:2013/3/22 18:18:00
--  发现一个代码应用速度问题

同样的代码,在命令窗口或窗口事件中执行的时候特慢,但是在窗口afterload中却飞快,这是为什么呢。

 

比如,http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&Id=30118 中,目录树有日期作为节点,但有0:00:00 。 要清楚这个0···,下面代码放在afterload中执行飞快, 但在命令窗口其他窗口事件按钮中都非常慢!

Dim tr As WinForm.TreeView = Forms("窗口1").Controls("TreeView1")
Dim nd As WinForm.TreeNode
For Each ndd As winform.treenode In tr.allnodes
    If ndd.text.contains("0:00:00")
        ndd.text = ndd.name.replace("0:00:00","")
    End If
Next

什么道理呢? 狐爸: 能改进吗 ?


--  作者:don
--  发布时间:2013/3/22 18:37:00
--  
Dim tr As WinForm.TreeView = Forms("窗口1").Controls("TreeView1")
Dim nd As WinForm.TreeNode

tr.StopRedraw
For Each ndd As winform.treenode In tr.allnodes
    If ndd.text.contains("0:00:00")
        ndd.text = ndd.name.replace("0:00:00","")
    End If
Next
tr.ResumeRedraw

--  作者:e-png
--  发布时间:2013/3/22 18:53:00
--  

呵呵,确实如此哈, 谢谢啊。 

 

但还是不理解在afterload中并没有加

 

tr.StopRedraw   

tr.ResumeRedraw
 
也一样运行飞快呢。。。

--  作者:狐狸爸爸
--  发布时间:2013/3/22 22:37:00
--  
这是因为这个时候窗口还没有显示,无需绘制。