如何让Listview滚动到指定位置

bhbcsdn 2000-12-03 09:27:00
加精
如何让Listview滚动到指定的某一行,具体点说,一个Listview有100秆数据,让第三十行滚动到第一行显示.
...全文
9828 18 打赏 收藏 转发到动态 举报
写回复
用AI写文章
18 条回复
切换为时间正序
请发表友善的回复…
发表回复
bhbcsdn 2000-12-17
  • 打赏
  • 举报
回复
to iProgram:
这个软件我己下载,等下网后我再看,多谢您了。
“楼隔板”呀,你们不常用楼上楼下相称吗,两层楼之间的小灰条不就是“楼隔板”吗.
iProgram 2000-12-17
  • 打赏
  • 举报
回复
“楼隔板”是什么东东?
iProgram 2000-12-17
  • 打赏
  • 举报
回复
Hi bhbcsdn:
API函数的参数确实是个头痛的问题,我记得有本书叫API大全之类的,不过很贵哦。
还有个软件我想推荐给你,是APIGuide,你可用这个连接下载http://www.vbgood.com/iprogram/down/apiguide.zip
该软件为每一个API函数都写了一个或多个例子。
bhbcsdn 2000-12-16
  • 打赏
  • 举报
回复
顺便问一下,怎么给已加过分的帖子再加分。
bhbcsdn 2000-12-16
  • 打赏
  • 举报
回复
to iProgram:
OK!好极了,这正是我所求的效果。看来SendMessage的用途还真是不小,但它的参数太多,请教i兄一下有没有这方面的资料借小弟一看,小弟邮箱就是“楼隔板”的超链接,谢谢!
misterzhao 2000-12-15
  • 打赏
  • 举报
回复
这个问题不错!
iProgram 2000-12-15
  • 打赏
  • 举报
回复
这样:
添加一个List1和一个Command1到Form1上,添加以下代码。运行后按Command1按钮看看是不是你想要的效果:
Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Const WM_VSCROLL = &H115
Private Sub Command1_Click()
Call ItemToTop(List1.hwnd, 30)
End Sub

Private Sub Form_Load()
Dim i As Long

For i = 1 To 100
List1.AddItem "List Item Of Line:" & i
Next i
End Sub

Private Sub ItemToTop(ByVal hwnd As Long, ByVal LineNum As Long)
'本子程序使LineNum行滚到第一行
Dim i As Long
SendMessage hwnd, WM_VSCROLL, 6, 0 '复原
For i = 1 To LineNum - 1
SendMessage hwnd, WM_VSCROLL, 1, 0 '下滚一行
Next i
End Sub
bhbcsdn 2000-12-15
  • 打赏
  • 举报
回复
to anstern:
Sorry,这个方法的确好使,我的测试代码添错地方了,但如果能滚动到指定的地方就更好了,不过这也很不错了,我这就给大家加分。
bhbcsdn 2000-12-15
  • 打赏
  • 举报
回复
依然如故。
anstern 2000-12-14
  • 打赏
  • 举报
回复
use this code:

listview1.listitem(30).EnsureVisible

this code can display the 30th item in listview,but not at the top!
If u want it at the top in listview, u must count your listview can display
how many items. Example:
If your listview can display 15 items, u should use this code
listview1.listitem(45).EnsureVisible

Thanks

guest 2000-12-12
  • 打赏
  • 举报
回复
最后一招:

for i=30 to 1 step -1
先在最后 添加一条记录

listview1.listitem.remove (i)



next
bhbcsdn 2000-12-09
  • 打赏
  • 举报
回复
皆不管用。
guest 2000-12-09
  • 打赏
  • 举报
回复
listview1.listitems(30).selected=true
thomasz2 2000-12-05
  • 打赏
  • 举报
回复
Set [listitem].visible=true
bhbcsdn 2000-12-03
  • 打赏
  • 举报
回复
如何Send?
pgfan 2000-12-03
  • 打赏
  • 举报
回复
sendmessage!
bhbcsdn 2000-12-03
  • 打赏
  • 举报
回复
to jinesc:
出错!显示“属性只读”。
guest 2000-12-03
  • 打赏
  • 举报
回复
ListView1.SelectedItem.Index = 30

7,785

社区成员

发帖
与我相关
我的任务
社区描述
VB 基础类
社区管理员
  • VB基础类社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧