469,926 Members | 1,701 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,926 developers. It's quick & easy.

Disabling Hscroll in ScrollableControl

I implemented a ScrollableControl and only want vertical scrolling. Every time I make the form smaller then the control
the control has h scroll bars even though I set it to false. I have the control anchored to all four corners. I watched the resize event and for some reason even if i keep setting hscroll to false it gets set back to true.



To manually override which scroll bars are visible, set the VScroll and HScroll properties. If either property is set to false, the corresponding scroll bar will not be visible, even if the AutoScroll property is set to true.

Public Class TestControl
Inherits System.Windows.Forms.ScrollableControl
Implements IContainerControl

Private myActiveControl As Control

#Region " Windows Form Designer generated code "

Public Sub New()

'This call is required by the Windows Form Designer.
' Make the container scrollable.

'Add any initialization after the InitializeComponent() call
Me.AutoScroll = True
Me.VScroll = True
Me.HScroll = False

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
End If
End If
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()
End Sub

#End Region

' Add implementation to the IContainerControl.ActiveControl property.
Public Property ActiveControl() As Control Implements IContainerControl.ActiveControl
Return Me.myActiveControl
End Get

Set(ByVal Value As Control)
' Make sure the control is a member of the ControlCollection.
If Me.Controls.Contains(value) Then
Me.myActiveControl = value
End If
End Set
End Property

' Add implementation to the IContainerControl.ActivateControl(Control) method.
Public Function ActivateControl(ByVal active As Control) As Boolean Implements IContainerControl.ActivateControl
If Me.Controls.Contains(active) Then
' Select the control and scroll the control into view if needed.
Me.myActiveControl = active
Return True
End If
Return False
End Function

Public Property MyHScroll() As Boolean
Return Me.HScroll
End Get
Set(ByVal Value As Boolean)
Me.HScroll = Value
End Set
End Property

End Class

Nov 20 '05 #1
0 1228

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by news.microsoft.com | last post: by
1 post views Thread by Gates72 | last post: by
3 posts views Thread by PB | last post: by
6 posts views Thread by Yehia A.Salam | last post: by
2 posts views Thread by Rune Jacobsen | last post: by
9 posts views Thread by 7stud | last post: by
5 posts views Thread by jehugaleahsa | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.