Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scrollbar visible in Panel

Status
Not open for further replies.

Viruland

Programmer
Dec 6, 2000
61
0
0
BE
Is there a way to check if a ScrollBar is visible in a Panel. I'v tried the following:


Dim aPanel as Panel
Dim blnVisible as boolean = aPanel.VScroll

The problem is that the method is protected.

Live fast, die young and leave a beautiful corpse behind.
 
The only way I know is to create an inherited panel control and expose the base HScroll and VScroll properties as public:
Code:
Public Class PanelEx
    Inherits System.Windows.Forms.Panel

#Region " Windows Form Designer generated code "

    Public Sub New()
        MyBase.New()

        'This call is required by the Windows Form Designer.
        InitializeComponent()

        'Add any initialization after the InitializeComponent() call

    End Sub

    'UserControl overrides dispose to clean up the component list.
    Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
        If disposing Then
            If Not (components Is Nothing) Then
                components.Dispose()
            End If
        End If
        MyBase.Dispose(disposing)
    End Sub

    'Required by the Windows Form Designer
    Private components As System.ComponentModel.IContainer

    'NOTE: The following procedure is required by the Windows Form Designer
    'It can be modified using the Windows Form Designer.  
    'Do not modify it using the code editor.
    <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
        components = New System.ComponentModel.Container()
    End Sub

#End Region

    Public ReadOnly Property VScrollVisible() As Boolean

        Get

            Return MyBase.VScroll

        End Get

    End Property

    Public ReadOnly Property HScrollVisible() As Boolean

        Get

            Return MyBase.HScroll

        End Get

    End Property

End Class
You can then put the panel on a form and check the visible status of the scroll bars:
Code:
MessageBox.Show(String.Format("HScrollVisible: {0}, VScrollVisible: {1}", PanelEx1.HScrollVisible, PanelEx1.VScrollVisible))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top