Login
网站首页 > 文章中心 > VB6

VB6 ListView1 根据 ID 选定 指定行

作者:小编 更新时间:2023-07-14 11:30:20 浏览量:107人看过

Private Sub Command32_Click()

    If ListView1.ListItems.Count > 0 Then ' VB6   ListView1 根据  ID 选定 指定行开始===========

    

            Dim strfindme As String

            

            Dim itmfound As ListItem '“founditem 变量”

            

            strfindme = 2  '这里设置需要直接查询的ID值就可以了@@@@@@@@@@@@@@@@@@@

            

            Set itmfound = ListView1.FindItem(strfindme, lvwText, , lvwPartial)

            

            If itmfound Is Nothing Then ' 若没有匹配成功,则通知用户并退出。

            

               gg.Caption = "没有找到可选定主机" & strfindme

            

            Else

            

                itmfound.EnsureVisible '滚动 listview 以显示找到的 listitem。

        

                itmfound.Selected = True '选定listitem。

        

                ListView1.SetFocus '将焦点返回给控件以查看选择

            

            End If

            

            Set itmfound = Nothing

    

    End If '选定结束=====================================

End Sub



版权声明:倡导尊重与保护知识产权,本站有部分资源、图片来源于网络,如有侵权,请联系我们修改或者删除处理。
转载请说明来源于"土嘎嘎" 本文地址:http://www.tugaga.com/jishu/vb/1186.html
<<上一篇 2023-07-12
下一篇 >> 2023-08-03

编辑推荐

热门文章