2013-04-23 106 views
0

我有一個包含一個列表框(listbox1)的用戶控件。水平滾動條不顯示在列表框中

horizo​​ntalscrollbar設置設置爲TRUE。

另一個列表框(selectionchanged)上還有一個處理程序,用於設置listbox1的值(以防這可能導致問題)。

我在一個TabControl這個用戶控件添加到一個標籤頁。

我面臨的問題是,即使列表框1中顯示的項目大於寬度,horizo​​ntalscrollbar也不會顯示。

任何人有一個想法,我可以解決這個問題?

感謝

CNC中 的要求儘可能多的代碼,我可以告訴

dim tabpage as new Tabpage 
dim dict as new dictionary(of String, list(of MyObject)) 
'fill dict 
tabpage.add(usercontrol(dict)) 
tabcontrol1.tabpages.add(tabpage) 

用戶控件:

class UserControl 
public sub new(dict) 
    Dim bs As BindingSource = New BindingSource(dict, Nothing) 
    ListBox1.DataSource = bs 
    ListBox1.DisplayMember = "Key" 
end sub 

Private Sub ListBox1_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ListBox1.SelectedIndexChanged 
    ListBox2.DataSource = New BindingSource(CType(ListBox1.SelectedItem, KeyValuePair(Of String, List(Of MyObject))).Value, Nothing) 
     End Sub 
End Class 
+0

你應該考慮顯示一些代碼。 – ahdaniels 2013-04-23 13:30:43

+0

沒有太多的代碼要顯示。使用設計器將listbox添加到usercontrol,並在desinger中將horizo​​ntalscrollbar的屬性設置爲true。然後添加usercontrol添加到一個tabpage。會發布一些東西... – benst 2013-04-23 13:34:30

回答

0

我已經想通了,爲什麼它沒有工作。只是我忽略的一小部分。我在這裏發佈這個,因爲它可能會幫助其他人。

如果列表已多列設置爲然後水平滾動條將不會顯示你(我)想。

關閉多列(當不需要時)或修復列寬將解決此問題。

主題可以關閉。