设置或更改列表框'滚动条值 [英] set or change a listbox' scrollbar value

查看:84
本文介绍了设置或更改列表框'滚动条值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试使用轨道栏控件生成的值来控制列表框滚动条

解决方案

 私有  Sub  ScrollListBox(框作为 ListBox,tBar 作为 TrackBar)
如果 Nothing OrElse tBar 没有 OrElse box.Items.Count< (box.Height \ box.ItemHeight)然后
返回
结束 如果
box.SuspendLayout()
Dim pct = tBar.Value /(tBar.Maximum - tBar.Minimum)
Dim pageItems = box.Height \ box.ItemHeight
Dim lbIndex = Math.Max( 0 CInt ((pct * box.Items.Count) - (pageItems / 2 )))
box.TopIndex = lbIndex
box.ResumeLayout()
结束 Sub


Trying to control a listbox scrollbar using values generated from a trackbar control

解决方案

Private Sub ScrollListBox(box As ListBox, tBar As TrackBar)
     If box Is Nothing OrElse tBar Is Nothing OrElse box.Items.Count < (box.Height \ box.ItemHeight) Then
         Return
     End If
     box.SuspendLayout()
     Dim pct = tBar.Value / (tBar.Maximum - tBar.Minimum)
     Dim pageItems = box.Height \ box.ItemHeight
     Dim lbIndex = Math.Max(0, CInt((pct * box.Items.Count) - (pageItems / 2)))
     box.TopIndex = lbIndex
     box.ResumeLayout()
 End Sub


这篇关于设置或更改列表框'滚动条值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆