我目前在一個表單上安置了ListView
,然後通過代碼隱藏向此ListView
添加按鈕。除了這樣一個事實:一旦有太多的項目添加到列表中,它不會創建一個垂直滾動條?我可以簡單地添加儘可能多的按鈕,而不需要創建一個按鈕?下面是將按鈕添加到列表中的代碼:VB:當添加太多項目時,ListView不會自動創建滾動條?
Dim x As Integer = 0
Dim btnCount As Integer = -1
Dim totalButtons As List(Of Button) = New List(Of Button)
Dim mItems As ListView.ListViewItemCollection =
New ListView.ListViewItemCollection(lstViewEditor)
For x = 0 To 14
'Create Button
Dim button As Button = New Button
button.Text = "0"
button.BackgroundImageLayout = ImageLayout.Center
button.BackColor = Color.WhiteSmoke
button.Width = ((Me.lstViewEditor.Width - 10)/15)
button.Height = button.Width
button.Location = New Point(x * (button.Width), 0)
'If start
If (Me.lstViewEditor.Controls.Count <= 14) Then
button.Text = "2"
button.BackColor = Color.Azure
End If
'Add To View
'Me.Controls.Add(button)
totalButtons.Add(button)
btnCount = totalButtons.Count - 1
AddHandler button.Click, AddressOf totalButtonHandler
Next
lstViewEditor.Controls.AddRange(totalButtons.ToArray)
任何幫助將不勝感激!我確實設置了Scrollable = true
我已經縮小到事實上,我添加控件到視圖,而不是添加一個項目集合。嘗試將按鈕添加到集合中以查看是否可能。 – 2011-06-10 22:50:44