listbox控件放置项目多时
listbox控件放置项目多时,它会自动显示垂直滚动条。如果不想让垂直滚动条显示,而且指定listbox项目的显示位置,应该如何处理?
--------------------编程问答--------------------
Public Class Form1
Private Declare Function ShowScrollBar Lib "user32 " (ByVal hwnd As Integer, ByVal wBar As Integer, ByVal bShow As Integer) As Integer
Private Const SB_BOTH = 3
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
For i As Integer = 0 To 5000
ListBox1.Items.Add(i)
Next
ListBox1.SelectedIndex = 1000 '显示指定位置
ShowScrollBar(ListBox1.Handle, SB_BOTH, False)
End Sub
Private Sub ListBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged
ShowScrollBar(ListBox1.Handle, SB_BOTH, False)
End Sub
End Class
补充:.NET技术 , VB.NET