Results 1 to 8 of 8

Thread: Overriding Panel ScrollBar Visibility

  1. #1

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    9

    Overriding Panel ScrollBar Visibility

    How do you set a Panels' aoutoscroll = true and not show the Verticle ScrollBar. The help I read says to "manually override and set VScroll=false". Does this mean create a new class, Inherit Panel, and overide the property VScroll?

    If so can you start me off with some code to override?

  2. #2
    Hyperactive Member NPassero's Avatar
    Join Date
    May 2007
    Location
    NJ
    Posts
    272

    Re: Overriding Panel ScrollBar Visibility

    vb Code:
    1. Panel1.VerticalScroll.Enabled = False
    2. ' or this :
    3.       Panel1.VerticalScroll.Visible = False
    4. ' try them both

  3. #3

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    9

    Re: Overriding Panel ScrollBar Visibility

    .VerticleScroll is not a member of Panel1 in VB.Net 2003 that I can find

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Overriding Panel ScrollBar Visibility

    You will want to override the StyleChanged event of the panel in question. Then check it for the style containing the WS_VSCROLL style.

    VB.NET 2003 Code:
    1. Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As IntPtr, ByVal nIndex As Integer) As Integer
    2.  
    3. Public Const GWL_STYLE As Integer = (-16)
    4. Public Const WS_VSCROLL As Integer = &H200000
    5.  
    6. Public Overridable Sub pnlPanel_StyleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles pnlPanel.StyleChanged
    7.     Dim bVScrollBar As Boolean
    8.     bVScrollBar = ((GetWindowLong(Me.pnlPanel.Handle, GWL_STYLE) And WS_VSCROLL) = WS_VSCROLL)
    9.     If bVScrollBar = True Then
    10.         'Remove vertical scrollbar
    11.     End If
    12. End Sub
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    9

    Re: Overriding Panel ScrollBar Visibility

    Thanks for the previous direction, Testing it however, I can not get the Verticle scroll bars to be removed or hidden




    Code:
    Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA" (ByVal hwnd As IntPtr, ByVal nIndex As Integer) As Integer
    
        Public Const GWL_STYLE As Integer = (-16)
        Public Const WS_VSCROLL As Integer = &H200000
    
        Public Overridable Sub pnlPanel_StyleChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Panel2.StyleChanged
            Dim bVScrollBar As Boolean
            bVScrollBar = ((GetWindowLong(Panel2.Handle, GWL_STYLE) And WS_VSCROLL) = WS_VSCROLL)
            If bVScrollBar = True Then
                bVScrollBar = False
                VScroll = False '????
            End If
        End Sub

  6. #6
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Overriding Panel ScrollBar Visibility

    You will need to write code to remove it.

    Use the SetWindowLong API and remove the vertical scrollbar style. Not sure if having items in it that warrent the vertical scrollbar will be an issue but just test it out.

    What do you plan don doing to make the controls visible in the panel? Rarrange them or ???
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  7. #7

    Thread Starter
    New Member
    Join Date
    Jun 2007
    Posts
    9

    Re: Overriding Panel ScrollBar Visibility

    In response to your last question I have a datagrid on one side of the page and a panel on the other. The datagrid holds representative time durations which are displayed in the panel via rectangular labels which represent a relative time line . Since both the datagrid and panel are the same heigth and their verticle scroll has to be tied together. I am using the dataGrids VScroll position to set the verticle Scroll of the Panel via code. Therefore the panels Verticle scroll is redundant and I would have to tie its movement back to the datagrids VScroll if I left it visible. The latter I do not know how to do --so I thaught it easier to make the panels VScroll Bar non visible.

    Would you approached the problem differently?

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Overriding Panel ScrollBar Visibility

    You can use the Panel1_Scroll event to reverse the mechanics of what you have in place for your datagrid but be careful not to create an infinate loop of scrolling events between the two. Create a boolean variable to identify which control is the source of the scroll.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width