下記のような ListView を継承した ユーザーコントロールを作成する ----------------------------------------------------------------------- ユーザーコントロールの作成方法については、下記を参考にして下さい。 http://www.atmarkit.co.jp/fdotnet/vblab/vb2005m_10/vb2005m_10_01.html ----------------------------------------------------------------------- Public Class myListView Public Event TopIndexChanged() Protected Overrides Sub WndProc(ByRef m As Message) Const WM_VSCROLL As Integer = &H115 Select Case m.Msg Case WM_VSCROLL RaiseEvent TopIndexChanged() End Select MyBase.WndProc(m) End Sub Protected Overrides Sub OnMouseWheel(ByVal e As MouseEventArgs) If e.Delta <> 0 Then RaiseEvent TopIndexChanged() End If End Sub Protected Overrides Sub OnKeyDown(ByVal e As KeyEventArgs) RaiseEvent TopIndexChanged() End Sub Protected Overrides Sub OnKeyUP(ByVal e As KeyEventArgs) RaiseEvent TopIndexChanged() End Sub End Class
スクロールの同期をとる場合(Form1 内で) Private Sub MyListView1_TopIndexChanged() Handles MyListView1.TopIndexChanged MyListView2.EnsureVisible(MyListView2.Items.Count - 1) MyListView2.EnsureVisible(MyListView1.TopItem.Index) End Sub
Private Sub MyListView2_TopIndexChanged() Handles MyListView2.TopIndexChanged MyListView1.EnsureVisible(MyListView1.Items.Count - 1) MyListView1.EnsureVisible(MyListView2.TopItem.Index) End Sub