Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

listBox problem

Status
Not open for further replies.

Smitty020

MIS
Jun 1, 2001
152
US
I'm having a problem moving the a selected Item (both displayValue and valueMember to another listBox.

I used the DataRowView to get a hold of both of them, and know I want to add them to another listBox.

I want the Display and Value members of the second listBox to be equal to the entry in the first listBox.

Thanks,
Smitty
 
You might want to be careful about using the exact same DataTable as the DataSource for both ListBoxes. I had similar issues that I had to resolve by using two separate instances of a DataTable as the DataSource for a ComboBox even though the contents of the DataTables were identical.
 
But you can use the same if you create a new BindingContext() for each ListBox

Here it's done with ComboBoxes but I think it is the same for ListBoxex. Some of the ComboBoxes uses the same table in DataHolder (that is a DataSet UserControl)

Code:
private void loadCombobox(ComboBox cb, string table, string displayMember) {
 cb.BindingContext = new BindingContext();
 cb.DataSource = Globals.DataHolder.Tables[table];
 cb.DisplayMember = cb.ValueMember = displayMember;
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top