以文本方式查看主题 - Foxtable(狐表) (http://www.foxtable.com/bbs/index.asp) -- 专家坐堂 (http://www.foxtable.com/bbs/list.asp?boardid=2) ---- 关于ListView的RowSelectionChanged事件 (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=115617) |
-- 作者:larjia -- 发布时间:2018/3/10 13:35:00 -- 关于ListView的RowSelectionChanged事件 代码如下: Forms("MainMenu").Open() Dim r As WinForm.ListView = e.Sender If r.SelectedRows(0).Text = "固定资产" Then msgbox ("固定资产") End If 希望找到当前的选中行。点击任一listviewrow,出现索引超出范围的报错。 代码哪里有问题? |
-- 作者:larjia -- 发布时间:2018/3/10 14:24:00 -- 我把代码改成如下,能达到效果。 1. 这样写是否正确? 2. 有更简单的方法吗? Dim lvw As WinForm.ListView = e.Sender Dim r As WinForm.ListViewRow For Each r In lvw.SelectedRows If r.Selected = True Then If r.Text = "固定资产" Then msgbox ("固定资产") End If End If Next |
-- 作者:有点蓝 -- 发布时间:2018/3/10 14:48:00 -- Dim r As WinForm.ListView = e.Sender If r.SelectedRows.count > 0 AndAlso r.SelectedRows(0).Text = "固定资产" Then msgbox ("固定资产") End If
|