Foxtable(狐表)用户栏目专家坐堂 → 求助(关于ListView死机的问题)


  共有1775人关注过本帖树形打印复制链接

主题:求助(关于ListView死机的问题)

帅哥哟,离线,有人找我吗?
jackyfashion
  1楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:655 积分:5085 威望:0 精华:0 注册:2013/10/7 22:27:00
求助(关于ListView死机的问题)  发帖心情 Post By:2017/4/11 23:43:00 [只看该作者]

大师:您好!
我的ListView代码:

RetrieveVirtualRow


If Tables("qrymyf").Rows.Count = 0 Then
    Return
End If
If Tables("qrymyf").current.IsNull("ltsu") = False Then
    Dim tt As Table = Tables("yywrkhtc")
    Dim lt = tt(0)("khtc") & "\"
    Dim lvw As WinForm.ListView = e.Sender
    lvw.StopRedraw
    'Dim dr As DataRow = DataTables("qrymyf").dataRows(e.Index) '根据行位置从数据表中取得对应的DataRow
    Dim drs = DataTables("qrymyf").Select("","ltsu DESC")
    Dim dr As DataRow = drs(e.Index) '根据行位置从数据表中取得对应的DataRow
    Dim Key As String = dr("ltsu")
    lvw.Images.LargeSize = New Size(90,120)
    lvw.Images.AddImage(Key,lt & Key & ".",lt & Key & ".")
    e.Row.Imagekey = key '指定图标键值
    e.Row.Tag = dr '将DataRow赋值给ListViewRow的Tag属性,将二者联系起来
    For Each cl As WinForm.ListViewColumn In lvw.Columns '逐列取值
        Select Case cl.Name
            Case "ffikgn","ffaa" '如果是人口列或面积列
                e.Row(cl.Name) = dr(cl.Name) '则显示千位分割符号
            Case Else
                e.Row(cl.Name) = dr(cl.Name)
                e.Row.ToolTipText = "设 计 师: " & dr("ymyfjgm") 
                Dim nm As String = dr("vdmh")
                Dim nm2 As String = dr("pjsy")
                If nm = False And nm2 = False Then
                    e.Row.ForeColor =  Color.White
                ElseIf nm = True And nm2 = False Then
                    e.Row.ForeColor =  Color.DeepSkyBlue
                ElseIf nm2 = True Then
                    e.Row.ForeColor =  Color.Lime
                End If
        End Select
    Next
    lvw.ResumeRedraw
End If

Click
Dim lvw As WinForm.ListView = e.Form.Controls("ListView1")
Dim vr As WinForm.ListViewRow = lvw.Current '获取ListView的当前行
If vr Is Nothing Then '如果不存在当前行,也就是内有选定任何一行
    Return
End If
Dim dr As DataRow = vr.tag '获取此行对应的DataRow
Dim ps As Integer = Tables("qrymyf").FindRow(dr)
If ps >= 0 Then
    Tables("qrymyf").Position = ps
    For Each cl As WinForm.ListViewColumn In lvw.Columns '逐列更新值
        vr(cl.Name) = dr(cl.Name)
        vr.Tag= dr
    Next
End If
单击时有时会死机
此行已从表中移除并且没有任何数据。BeginEdit() 将允许在此行中创建新数据

.NET Framework 版本:2.0.50727.8745
Foxtable 版本:2017.3.18.1
错误所在事件:窗口,qrymyf,ListView1,Click
详细错误信息:
此行已从表中移除并且没有任何数据。BeginEdit() 将允许在此行中创建新数据
谢谢!


 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106209 积分:540168 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2017/4/12 8:40:00 [只看该作者]

RetrieveVirtualRow之后是不是重新加载过“qrymyf”表?

如果是那需要重新刷新ListView1的数据,不然就记录主键,如e.Row.Tag = dr("主键"),后面使用的时候通过主键获取行数据

 回到顶部
帅哥哟,离线,有人找我吗?
jackyfashion
  3楼 | QQ | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:三尾狐 帖子:655 积分:5085 威望:0 精华:0 注册:2013/10/7 22:27:00
  发帖心情 Post By:2017/4/12 20:45:00 [只看该作者]

谢谢!!!

 回到顶部