问题描述
我正在尝试制作ToolStrip滚动条,但如何在???
上使用Form im捕获滚动更改?
导入System.Windows.Forms.Design
导入System.ComponentModel
< toolstripitemdesigneravailability(toolstripitemdesigneravailability.toolstrip)> _
公共类ToolStripScroller
继承ToolStripControlHost
专用滚动条作为新的HScrollBar()
Public Sub New()
MyBase.New(New FlowLayoutPanel())
MyBase.Margin =新填充(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
结束子
受保护的重写Sub Finalize()
MyBase.Finalize()
结束子
公共子OnScroll(发送者为System.Object,ByVal e为ScrollEventArgs)
''MyBase.OnScroll(e)
结束
私有_Value作为整数
< defaultvalue(10)> _
公共属性Value()为整数
获取
返回_Value
结束获取
设置(ByVal值作为整数)
_Value =值
Scroller.Value = _Value
Me.Invalidate()
端套
最终财产
私有_Maximum As Integer
< defaultvalue(100)> _
公共属性Maximum()作为整数
获取
返回_Maximum
结束获取
设置(ByVal值作为整数)
_Maximum =值
Scroller.Maximum = _Maximum
Me.Invalidate()
端套
最终财产
私有_Minimum As Integer
< defaultvalue(0)> _
公共属性Minimum()作为整数
获取
返回_Minimum
结束获取
设置(ByVal值作为整数)
_Minimum =值
Scroller.Minimum = _Minimum
Me.Invalidate()
端套
最终财产
结束类
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
推荐答案
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
这篇关于工具条中的HScrollBar(滚动更改)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!