none
FlowLayoutPanel 不显示滚动条。如何实现上下滚动。 RRS feed

  • 问题

  • FlowLayoutPanel  不显示滚动条。如何实现上下滚动。 这是我实现的方式。但是滚动的时候,会显示一下滚动条。又隐藏。(一闪而过的感觉)感觉不美观。请大家指导一下。谢谢。

     Public Sub TestScroll(ByVal i As Integer)
            Dim a As Integer = i + FlowLayoutPanel1.VerticalScroll.SmallChange
            If (FlowLayoutPanel1.VerticalScroll.Maximum < a) Then
                FlowLayoutPanel1.VerticalScroll.Value = FlowLayoutPanel1.VerticalScroll.Maximum
            Else
                FlowLayoutPanel1.VerticalScroll.Value = a
            End If
        End Sub
    如图。按上、下按钮下面的FlowLayoutPanel1上下滚动。谢谢。


    • 已编辑 可推 2015年5月11日 14:44 补充说明
    2015年5月11日 13:11

答案

  • 你好,

    我建议你把这个FlowlayoutPanel放到另一个Panel中,设置FlowLayoutPanel的属性如下:

    FlowLayoutPanel1.AutoScroll = False
    FlowLayoutPanel1.AutoSize = True
    FlowLayoutPanel1.AutoSizeMode = AutoSizeMode.GrowAndShrink
    FlowLayoutPanel1.FlowDirection = FlowDirection.TopDown

    然后用两个button来控制滑动即可。Click事件如下。

    Public i As Integer = 25  ‘每次滑动的距离
        Private Sub BtnDown_Click(sender As Object, e As EventArgs) Handles BtnDown.Click
            Dim y As Integer = Me.FlowLayoutPanel1.Location.Y - i
            If y <= Panel1.Height - FlowLayoutPanel1.Height Then
                y = Panel1.Height - FlowLayoutPanel1.Height
            End If
            Me.FlowLayoutPanel1.Location = New Point(Me.FlowLayoutPanel1.Location.X, y)
        End Sub
        
        Private Sub BtnUp_Click(sender As Object, e As EventArgs) Handles BtnUp.Click
            Dim y As Integer = Me.FlowLayoutPanel1.Location.Y + i
            If y >= 0 Then
                y = 0
            End If
            Me.FlowLayoutPanel1.Location = New Point(Me.FlowLayoutPanel1.Location.X, y)
        End Sub



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • 已标记为答案 可推 2015年5月12日 13:20
    2015年5月12日 7:56
    版主

全部回复

  • 你好,

    我建议你把这个FlowlayoutPanel放到另一个Panel中,设置FlowLayoutPanel的属性如下:

    FlowLayoutPanel1.AutoScroll = False
    FlowLayoutPanel1.AutoSize = True
    FlowLayoutPanel1.AutoSizeMode = AutoSizeMode.GrowAndShrink
    FlowLayoutPanel1.FlowDirection = FlowDirection.TopDown

    然后用两个button来控制滑动即可。Click事件如下。

    Public i As Integer = 25  ‘每次滑动的距离
        Private Sub BtnDown_Click(sender As Object, e As EventArgs) Handles BtnDown.Click
            Dim y As Integer = Me.FlowLayoutPanel1.Location.Y - i
            If y <= Panel1.Height - FlowLayoutPanel1.Height Then
                y = Panel1.Height - FlowLayoutPanel1.Height
            End If
            Me.FlowLayoutPanel1.Location = New Point(Me.FlowLayoutPanel1.Location.X, y)
        End Sub
        
        Private Sub BtnUp_Click(sender As Object, e As EventArgs) Handles BtnUp.Click
            Dim y As Integer = Me.FlowLayoutPanel1.Location.Y + i
            If y >= 0 Then
                y = 0
            End If
            Me.FlowLayoutPanel1.Location = New Point(Me.FlowLayoutPanel1.Location.X, y)
        End Sub



    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • 已标记为答案 可推 2015年5月12日 13:20
    2015年5月12日 7:56
    版主
  • 谢谢。终于明白这个道理了。使用FlowLayoutPanel1.LocationPanel1 的改变实现滚动。确实这样实现了很好的滚动效果。 
    2015年5月12日 13:20