Transpose datagrid row to corresponding label text

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a datagrid containing data from an xml file. Is it possible that when
a row on the datagrid is clicked these results can update a series of
corresponding labels elsewhere on the form? e.g. the datagrid contains the
columns, FirstName and LastName. When a row is highlighted I'd like the
selected FirstName and LastName to appear in labels at the top of the form.
 
Hi,

If you bind the datagrid and the labels to the same data source
the currency manger will keep them in sync. Here is an example.

Dim strConn As String

Dim strSQL As String

Dim da As OleDbDataAdapter

Dim ds As New DataSet


Dim conn As OleDbConnection

strConn = "Provider = Microsoft.Jet.OLEDB.4.0;"

strConn &= "Data Source = Northwind.mdb;"

conn = New OleDbConnection(strConn)

da = New OleDbDataAdapter("Select * From Categories", conn)

da.Fill(ds, "Categories")

daEmployees = New OleDbDataAdapter("Select * From Employees Order by
LastName, FirstName", conn)

daEmployees.Fill(ds, "Employees")

DataGrid1.DataSource = ds.Tables("Categories")

TextBox1.DataBindings.Add("Text", ds.Tables("Categories"), "Description")



Ken

-----------------

I have a datagrid containing data from an xml file. Is it possible that when
a row on the datagrid is clicked these results can update a series of
corresponding labels elsewhere on the form? e.g. the datagrid contains the
columns, FirstName and LastName. When a row is highlighted I'd like the
selected FirstName and LastName to appear in labels at the top of the form.
 
Back
Top