Na formuláři DataGridView1, Label1 a Label2, DataTable simuluje vaše DataSource a labely se aktualizují při změně řádku:
Public Class Form1
Dim dt As DataTable
Public Sub New()
' This call is required by the Windows Form Designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
dt = New DataTable
With dt
.Columns.Add("Číslo", Type.GetType("System.Int32"))
.Columns.Add("Jméno", Type.GetType("System.String"))
.Rows.Add(1, "Tomáš")
.Rows.Add(2, "Ondřej")
.Rows.Add(3, "Martin")
.Rows.Add(4, "Pavel")
.Rows.Add(5, "Jarda")
.Rows.Add(6, "Jana")
.Rows.Add(7, "Lucka")
.Rows.Add(8, "Gábina")
End With
Me.DataGridView1.DataSource = dt
Me.Label1.DataBindings.Add("Text", Me.DataGridView1.DataSource, "Číslo")
Me.Label2.DataBindings.Add("Text", Me.DataGridView1.DataSource, "Jméno")
End Sub
End Class
|