如何隐藏仍在滚动的滚动条?

时间:2019-07-12 04:48:56

标签: c# vb.net

滚动条有问题。

我使用面板中的滚动功能查看信息

但是滚动条会缩短信息,导致宽度大小固定

所以我要删除或隐藏滚动条

您有什么解决的办法吗?

2 个答案:

答案 0 :(得分:0)

好吧,这是vb.net,经过测试,panel1内的panel2,panel2的宽度比panel1大:

Public Class Form1

Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load

    Panel1.HorizontalScroll.Visible = False
    Panel1.VerticalScroll.Visible = False

    Panel2.AutoScroll = True
    Panel2.HorizontalScroll.Visible = False
    Panel2.VerticalScroll.Visible = True

End Sub

Private Sub Panel2_MouseWheel(sender As Object, e As System.Windows.Forms.MouseEventArgs) Handles Panel2.MouseWheel
    If Panel2.Bounds.Contains(e.Location) Then
        Dim vScrollPosition As Integer = Panel2.VerticalScroll.Value
        vScrollPosition = e.Location.Y
        Panel2.Invalidate()
    End If
End Sub

Private Sub Panel2_MouseEnter(sender As Object, e As EventArgs) Handles Panel2.MouseEnter
    Panel2.Select()
End Sub

End Class

答案 1 :(得分:0)

您只需在代码中需要的地方使用它来停用滚动条即可。

panel1.AutoScroll = false;