Click here to Skip to main content
16,014,677 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Im trying to make a ToolStrip Scrollbar, but how to catch the Scroll change on the Form im using it on ???



Imports System.Windows.Forms.Design
Imports System.ComponentModel


<toolstripitemdesigneravailability(toolstripitemdesigneravailability.toolstrip)> _
Public Class ToolStripScroller
Inherits ToolStripControlHost

Private Scroller As New HScrollBar()

Public Sub New()
MyBase.New(New FlowLayoutPanel())
MyBase.Margin = New Padding(0, 5, 0, 2)

Scroller.Width = 140
MyBase.Control.Controls.Add(Scroller)

Me.Maximum = 100
Me.Minimum = 0
Me.Value = 10

AddHandler Scroller.Scroll, AddressOf Me.OnScroll

End Sub

Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub

Public Sub OnScroll(sender As System.Object, ByVal e As ScrollEventArgs)
'MyBase.OnScroll(e)
End Sub



Private _Value As Integer
<defaultvalue(10)> _
Public Property Value() As Integer
Get
Return _Value
End Get
Set(ByVal value As Integer)
_Value = value
Scroller.Value = _Value
Me.Invalidate()
End Set
End Property

Private _Maximum As Integer
<defaultvalue(100)> _
Public Property Maximum() As Integer
Get
Return _Maximum
End Get
Set(ByVal value As Integer)
_Maximum = value
Scroller.Maximum = _Maximum
Me.Invalidate()
End Set
End Property

Private _Minimum As Integer
<defaultvalue(0)> _
Public Property Minimum() As Integer
Get
Return _Minimum
End Get
Set(ByVal value As Integer)
_Minimum = value
Scroller.Minimum = _Minimum
Me.Invalidate()
End Set
End Property

End Class
Posted
Updated 22-Apr-12 0:40am
v2

1 solution

I find a solution :

ASM
AddHandler Scroller.Scroll, AddressOf HandleScroll


Public Event Scroll As EventHandler

Private Sub HandleScroll(ByVal sender As Object, ByVal e As ScrollEventArgs)
  RaiseEvent Scroll(Me, e)
End Sub
 
Share this answer
 
Comments
Klaus (Germany) 20-Nov-18 11:56am    
Hello,
please help me.
Which lines of code are needed to take over the most important EventHandlers?
Example: ValueChanged, SizeChanged, etc...
The element is not displayed correctly.
If e.g. the AutoSize = False is set.
Thanks for your help.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900