Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共5 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]帮忙分析代码哪出错了?

1楼
紙上不談兵 发表于:2011/8/26 11:49:00
把此文件替换范例的[目录树管理],代码详见AfterSelectNode,
想法:设置节点BackColor,标记最近选择4个节点.

随便选择节点,点击多次就会间中报错!实在不知哪错了?请大家帮忙分析一下,多谢!

 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:目录树管理.table



图片点击可在新窗口打开查看此主题相关图片如下:000.gif
图片点击可在新窗口打开查看
2楼
狐狸爸爸 发表于:2011/8/26 12:09:00

If Lsj.Contains(e.Node.Text) = False Then
   Lsj.Add(e.Node.Text)
End If
e.Form.Controls("TextBox2").value =Nothing
For Each s As String In Lsj  
    e.Form.Controls("TextBox2").value += "," & s
Next

If Lsj.count>3 Then
    For Each nd As WinForm.TreeNode In e.Sender.AllNodes
        If nd.Text = Lsj(0) Then
            nd.BackColor = Color.White
            Lsj.RemoveAt(0)
            If lsJ.Count =0 Then
                Exit For
            End If
        End If
    Next  
End If

For Each nd As WinForm.TreeNode In e.Sender.AllNodes
    For Each s As String In Lsj
        If nd.Text = s Then
            nd.BackColor = Color.LightGray
        End If
    Next
Next

3楼
紙上不談兵 发表于:2011/8/26 12:34:00
以下是引用狐狸爸爸在2011-8-26 12:09:00的发言:

If Lsj.Contains(e.Node.Text) = False Then
   Lsj.Add(e.Node.Text)
End If
e.Form.Controls("TextBox2").value =Nothing
For Each s As String In Lsj  
    e.Form.Controls("TextBox2").value += "," & s
Next

If Lsj.count>3 Then
    For Each nd As WinForm.TreeNode In e.Sender.AllNodes
        If nd.Text = Lsj(0) Then
            nd.BackColor = Color.White
            Lsj.RemoveAt(0)
            If lsJ.Count =0 Then
                Exit For
            End If
        End If
    Next  
End If

For Each nd As WinForm.TreeNode In e.Sender.AllNodes
    For Each s As String In Lsj
        If nd.Text = s Then
            nd.BackColor = Color.LightGray
        End If
    Next
Next


多谢先!

这个是不报错了,只是有点不明:我设置了If Lsj.count>3 Then才执行If...End if里面的代码呀,为何里面还须 

If lsJ.Count =0 Then

       Exit For
End If            呢?
且虽不报错,但有时结果不对:见图,TextBox2显示Lsj有[数码产品,电脑,电脑配件,机箱,主板]5个值,但标记只有[主板]

图片点击可在新窗口打开查看此主题相关图片如下:00.gif
图片点击可在新窗口打开查看

4楼
紙上不談兵 发表于:2011/8/26 13:11:00

明白哪出错了:如不加Exit For,则Lsj为空时执行RemoveAt(0)会报错!多谢狐爸,正确的是:


If Lsj.Contains(e.Node.Text) = False Then
   Lsj.Add(e.Node.Text)
End If

If Lsj.count>3 Then
    For Each nd As WinForm.TreeNode In e.Sender.AllNodes
        If nd.Text = Lsj(0) Then
            nd.BackColor = Color.White
            Lsj.RemoveAt(0)      
               Exit For        
        End If
    Next   
End If


For Each nd As WinForm.TreeNode In e.Sender.AllNodes
    For Each s As String In Lsj
        If nd.Text = s Then
            nd.BackColor = Color.LightGray
        End If
    Next
Next

5楼
狐狸爸爸 发表于:2011/8/26 14:03:00

图片点击可在新窗口打开查看

共5 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .02734 s, 3 queries.