【问题标题】:horizontal scrollbar not showing in listbox列表框中不显示水平滚动条
【发布时间】:2013-04-24 22:00:15
【问题描述】:

我有一个包含列表框 (listbox1) 的用户控件。

水平滚动条设置为 TRUE。

另一个列表框 (selectionchanged) 上还有一个处理程序,用于设置 listbox1 的值(以防这可能导致问题)。

我将此用户控件添加到选项卡控件中的选项卡页中。

我面临的问题是,即使listbox1中显示的项目大于宽度,也不会显示水平滚动条。

有人知道我该如何解决这个问题吗?

谢谢

-编辑- 根据要求尽可能多地显示代码

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

【问题讨论】:

  • 你应该考虑展示一些代码。
  • 没有太多代码可以展示。使用设计器将列表框添加到用户控件,并在设计器中将 Horizo​​ntalscrollbar 的属性设置为 true。然后添加用户控件添加到一个标签页。会发布一些东西...

标签: vb.net listbox horizontal-scrolling


【解决方案1】:

我已经弄清楚为什么它不起作用了。只是我忽略的一个小设置。 我在此处发布此内容,因为它可能对其他人有所帮助。

如果列表框的 multiColumn 设置为 True,则水平滚动条将不会按照您(我)的意愿显示。

关闭多列(不需要时)或修复列宽将解决此问题。

主题可以关闭。

【讨论】:

    猜你喜欢
    • 2016-01-08
    • 1970-01-01
    • 2015-03-06
    • 2014-11-05
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-13
    • 1970-01-01
    相关资源
    最近更新 更多