以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  ListView拖动行报错  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=144254)

--  作者:fendouww
--  发布时间:2019/12/15 11:43:00
--  ListView拖动行报错
ListView拖动行报错
这是窗口启动代码
Dim tday As Date = Date.Today
Dim fl As WinForm.PictureViewer = e.Form.Controls("PictureViewer1")
fl.DeleteCommand.Enabled = False
fl.AddCommand.Enabled = False
fl.ClearCommand.Enabled = False

Dim lvw1 As WinForm.ListView = e.Form.Controls("ListView1") \'员工列表
Dim lvw2 As WinForm.ListView = e.Form.Controls("ListView2") \'活动一参与者列表
Dim lvw3 As WinForm.ListView = e.Form.Controls("ListView3") \'活动二参与者列表
Dim lvw4 As WinForm.ListView = e.Form.Controls("ListView4") \'活动二参与者列表
Dim lvw5 As WinForm.ListView = e.Form.Controls("ListView5") \'活动二参与者列表
Dim lvw6 As WinForm.ListView = e.Form.Controls("ListView6") \'活动二参与者列表

Dim lvw8 As WinForm.ListView = e.Form.Controls("ListView8") \'活动二参与者列表
Dim lvw9 As WinForm.ListView = e.Form.Controls("ListView9") \'活动二参与者列表
Dim lvw10 As WinForm.ListView = e.Form.Controls("ListView10") \'活动二参与者列表
Dim lvw11 As WinForm.ListView = e.Form.Controls("ListView11") \'活动二参与者列表
Dim lvw12 As WinForm.ListView = e.Form.Controls("ListView12") \'活动二参与者列表


Dim lvws() As Winform.ListView = {lvw1,lvw2,lvw3,lvw4,lvw5,lvw6,lvw8,lvw9,lvw10,lvw11,lvw12} \'看看我们是怎样批量设置某组控件属性的
For Each lvw As WinForm.ListView In lvws
\'lvw.View = ViewMode.Details
 lvw.AllowDrag = True
 lvw.AllowDrop = True
\'  lvw.Images.AddSmallImage("Man", "Man.ico") \'添加代表男性的一对图标
\'  lvw.Images.AddSmallImage("Woman", "Woman.ico") \'添加代表女性的一对图标
Next


Dim cls() As String = {"下单日期","设计师","开发品类","打样款号"} \'定义列名
Dim wds() As Integer = {130,50,72,85} \'定义列宽

Dim cls2() As String = {"下单日期","设计师","开发品类","打样款号","目标样板交期"} \'定义列名
Dim wds2() As Integer = {110,50,72,85,80} \'定义列宽

Dim cls3() As String = {"下单日期","设计师","开发品类","打样款号","要求成衣日期"} \'定义列名
Dim wds3() As Integer = {110,50,72,85,80} \'定义列宽

lvw1.StopRedraw() \'停止绘制
lvw1.Groups.Clear()
lvw1.Columns.Clear() \'清除原来的列
lvw1.Rows.Clear() \'清除原来的行
lvw1.Images.Clear() \'清除原来的图片
lvw1.View = ViewMode.Details \'显示模式为详细信息
For i As Integer = 0 To  cls.Length - 1  \'增加列
    Dim c As WinForm.ListViewColumn = lvw1.Columns.Add()
    c.Name = cls(i) \'指定列名
    c.Text = cls(i) \'指定标题,这里标题和列名相同
    c.Width = wds(i) \'指定列宽
Next

For Each zh As String In DataTables("样衣开发").GetValues("开发状态") \'增加分组
    Dim grp As WinForm.ListViewGroup = lvw1.Groups.Add()
    grp.Name = zh
    grp.Text = zh & "订单"
Next
Dim drs As List(of DataRow) = DataTables("样衣开发").Select("(开发状态 = \'待审核\' or 开发状态 = \'待分配\') and (角色 <> \'果壳\' or 角色 is null)","下单日期")
For Each dr As DataRow In drs
    Dim r As  WinForm.ListViewRow =  lvw1.Rows.Add() \'增加一行
    r.Group = dr("开发状态")  \'指定所属分组
    For Each cl As String In cls \'逐列取值
        r(cl) = dr(cl)
    Next
    r.Tag = dr
Next
lvw1.ResumeRedraw()

[此贴子已经被作者于2019/12/16 10:29:08编辑过]

--  作者:有点蓝
--  发布时间:2019/12/15 20:22:00
--  
报什么错误?
--  作者:fendouww
--  发布时间:2019/12/16 8:33:00
--  
图片显示
--  作者:有点蓝
--  发布时间:2019/12/16 9:06:00
--  
什么图片?http://foxtable.com/bbs/dispbbs.asp?boardid=2&Id=78
--  作者:fendouww
--  发布时间:2019/12/16 10:47:00
--  
.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2019.12.8.1
错误所在事件:窗口,审核申请,ListView3,RowSelectionChanged
详细错误信息:
无法将类型为“System.Windows.Forms.ListViewItem”的对象强制转换为类型“Foxtable.oo_o0_o0”。


截图传不了,这是报错信息
[此贴子已经被作者于2019/12/16 10:47:33编辑过]

--  作者:有点蓝
--  发布时间:2019/12/16 10:50:00
--  
检查这个事件代码,错误所在事件:窗口,审核申请,ListView3,RowSelectionChanged
--  作者:fendouww
--  发布时间:2019/12/16 11:07:00
--  
Dim lvw As WinForm.ListView = e.Form.Controls("ListView2")
Dim vr As WinForm.ListViewRow = lvw.Current \'获取ListView的当前行
If vr Is Nothing Then \'如果不存在当前行,也就是内有选定任何一行
    Return
End If
Dim dr As DataRow = vr.tag \'获取此行对应的DataRow

Dim id As String = dr("_Identify")
Dim Filter As String = "[_Identify] = " & id

Dim pd As Integer = Tables("样衣开发").FindRow(dr)
If pd < 0 Then
DataTables("样衣开发").AppendLoad(Filter)
End If
Dim ps As Integer = Tables("样衣开发").FindRow(dr)
If ps >= 0 Then
    Tables("样衣开发").Position = ps
    Dim fl As WinForm.PictureViewer = e.Form.Controls("PictureViewer1")
    fl.DeleteCommand.Enabled = False
fl.AddCommand.Enabled = False
    fl.ClearCommand.Enabled = False
    For Each cl As WinForm.ListViewColumn In lvw.Columns \'逐列更新值
        vr(cl.Name) = dr(cl.Name)
    Next
End If

--  作者:有点蓝
--  发布时间:2019/12/16 11:54:00
--  
看不出什么问题。上传实例测试一下