Classファイルを追加
Public Class クラス名 の次の行に
Inherits ListBox
を追加
Windows の メッセージを定義
private const WM_VSCROLL as Integer = &H115
' 前回のスクロール位置を記憶する変数
private nOldValue as Integer
' クライアントに公開するイベントを定義
Public Event Scroll(Sender as Object, e as ScrollEventArgs)
' 内部使用のハンドラを定義
Protected Overridable Sub OnScroll(Se as ScrollEventArgs)
__ RaiseEvent Scroll(me,se)
End Sub
' イベント生成のため WndProcを定義
Protected Overrides sub WndProc(ByRef m as System.Windows.Forms.Message)
__ ' メッセージの判定
__ if m.msg =WM_VSCROLL then
__ __ ' 引数生成のために wParamを取得
__ __ dim wParam as Integer = m.WParam.ToInt32
__ __ dim sbType as integr
__ __ dim nPos as Integer
__ __ ' ユーザーが行ったアクションと データを取得
__ __ sbType = wParam and &HFFFF
__ __ nPos = (wParam and &HFFFF0000)/&H10000
__ __ 'イベントハンドラの引数を生成
__ __ dim e as new ScrllEventArgs(sbType, nOldValue, nPos, ScrollOrientation.VerticalScroll)
__ __ ’ イベントを呼ぶ
__ __ OnScroll(e)
__ __ if e.Type = ScrollEventType.ThumbTrack or _
__ __ __ e.Type = ScrollEventType.ThrumbPosition then
__ __ __ ' つまみを動かした場合 位置を記憶
__ __ __ nOldValue = nPos
__ __ end if
__ end if
__ MyBase.WndProc(m)
End Sub
といった具合の クラスを追加して 一度『ビルド』します
出来上がった 新しいクラスのコントロール をフォームに貼り付け
Scrollイベントが プロパティにあるので追加してください