The simplest way is to create a binding between the two with
DataBindings.Add() which is accessible as a property of the control that you
want to automatically update.
A simple example of this would be a ListBox and a ComboBox bound to the same
data, in order to have the SelectedValue in the ListBox be the same as what
the ComboBox has been set to, you would simply do the following:
listBox1.DataBindings.Add("SelectedValue", comboBox1, "SelectedValue");
The above example assumes that the property specified by the ValueMember of
both controls is the same and unique within the list.
Brendan
"Alpha" wrote:
How do I change the selected item in a listbox according to a Combox's
selected item on the same form? The Combox is from a different table in the
same dataset as the Listbox uses. Combox's ValueMember is a ID that is a
column in the table that the listbox uses. Is there a way to link these 2's
relation so that when the user changes the selection in the Combox the list
box would automacticall changes to reflect the items that's linked to the
combox selection?
Thanks, Alpha