You can use a BindingManagerBase to manage the data binding. You can use it
like a navigator. This is a sample code of BindingManagerBase:
textSurname.DataBindings.Add(new System.Windows.Forms.Binding("Text", ds, "
bmSurname = this.BindingContext [ds, " Employees "];
bmSurname.Position = listFullname.SelectedIndex;
For more information about BindingManagerBase please see:
Alternatively, you can fill the text box by yourself by using the
SelectedItem property. The SelectedItem is a DataRowView. It is more
DataRowView row = (DataRowView) listFullname.SelectedItem;
textName.Text = row["Surname "] + " " + row["GivenName"];
I hope this is helpful.
Lion Shi, MCSE, MCSD
Microsoft Support Engineer
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
Subject: RC1, Listbox databinding
Date: Tue, 8 Jan 2002 19:36:52 -0800
X-Newsreader: Microsoft CDO for Windows 2000
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
NNTP-Posting-Host: TKMSFTNGXA13 10.201.226.41
Xref: cpmsftngxa09 microsoft.public.dotnet.framework.windowsforms:8721
I have a dataset table created with the following select:
SELEXT EmpID, Surname, GivenName, Surname + ', ' +
GivenName AS FullName FROM Employees ORDER BY Surname,
EmpID is an identity column and is the primary key.
Surname and GivenName are bound to textboxes and Fullname
is bound to a listbox as ...
DataSource = "Employees"
DisplayMember = "FullName"
ValueMember = "EmpID"
SelectedItem = "Employees.EmpID"
How do I move the position of the data in the textboxes in
response to the listbox's SelectionChanged event?