大师:您好!
我的ListView代码:
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() 将允许在此行中创建新数据
谢谢!