自动聚焦在列表视图中的选择行? [英] auto focus on select line in listview?
本文介绍了自动聚焦在列表视图中的选择行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以帮助我吗?我想滚动自动选择点:
这是我的代码
can any one help me?? i want scroll to select point automatically:
here is my code
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
ListView1.View = View.Details
ListView1.FullRowSelect = True
ListView1.GridLines = True
ListView1.Columns.Add("ID", 40)
For i As Integer = 0 To 20
ListView1.Items.Add(i)
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListView1.Items(10).Selected = True
ListView1.Select()
End Sub
End Class
当我单击button1时,它正确选择了第10个项目,但是滚动条无法转到所选项目的问题,请帮助我
在此先感谢
When i click on button1 it selected item 10 correctly, but the problem the scroll not go to that selected, please help me
Thanks in advance
推荐答案
使用 ^ ].
Use the EnsureVisible Method[^].
MSDN写道:
确保该项在控件中可见,并在必要时滚动控件的内容.
Ensures that the item is visible within the control, scrolling the contents of the control, if necessary.
将ListView1.Items(10).EnsureVisible()
添加到您的Button1_Click
函数中.
Add ListView1.Items(10).EnsureVisible()
to your Button1_Click
function.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
ListView1.Items(10).Selected = True
ListView1.Items(10).EnsureVisible()
ListView1.Select()
End Sub
这篇关于自动聚焦在列表视图中的选择行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文