Partial Public Class Form1 Inherits System.Windows.Forms.Form #Region "デモ用コントロールの配置" Private panel As SplitContainer Private WithEvents dgv1 As DataGridView Private WithEvents dgv2 As DataGridView Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs) Handles MyBase.Load panel = New SplitContainer() panel.Orientation = Orientation.Horizontal panel.Dock = DockStyle.Fill Controls.Add(panel) dgv1 = New DataGridView() dgv1.Dock = DockStyle.Fill dgv1.AllowDrop = False dgv2 = New DataGridView() dgv2.Dock = DockStyle.Fill dgv2.AllowDrop = True panel.Panel1.Controls.Add(dgv1) panel.Panel2.Controls.Add(dgv2) dgv1.AllowUserToAddRows = False dgv1.ReadOnly = True dgv1.ColumnCount = 3 dgv1.RowCount = 20 dgv1.MultiSelect = False dgv1.SelectionMode = DataGridViewSelectionMode.FullRowSelect dgv2.AllowUserToAddRows = False dgv2.ReadOnly = True dgv2.ColumnCount = 3 dgv2.RowCount = 10 dgv2.MultiSelect = False dgv2.SelectionMode = DataGridViewSelectionMode.FullRowSelect For rowIndex As Integer = 0 To 19 dgv1(0, rowIndex).Value = String.Format("{0}-0", rowIndex) dgv1(1, rowIndex).Value = String.Format("{0}-1", rowIndex) dgv1(2, rowIndex).Value = String.Format("{0}-2", rowIndex) Next For rowIndex As Integer = 0 To 9 dgv2(0, rowIndex).Value = String.Format("{0}-A", rowIndex) dgv2(1, rowIndex).Value = String.Format("{0}-B", rowIndex) dgv2(2, rowIndex).Value = String.Format("{0}-C", rowIndex) Next End Sub #End Region End Class