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?
Re: Overriding Panel ScrollBar Visibility
vb Code:
Panel1.VerticalScroll.Enabled = False
' or this :
Panel1.VerticalScroll.Visible = False
' try them both
Re: Overriding Panel ScrollBar Visibility
.VerticleScroll is not a member of Panel1 in VB.Net 2003 that I can find
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:
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 pnlPanel.StyleChanged
Dim bVScrollBar As Boolean
bVScrollBar = ((GetWindowLong(Me.pnlPanel.Handle, GWL_STYLE) And WS_VSCROLL) = WS_VSCROLL)
If bVScrollBar = True Then
'Remove vertical scrollbar
End If
End Sub
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
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 ???
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?
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.