Binding to a property of a current item from another binded list

Go To StackoverFlow.com

1

I've got a list of Definition objects (definitions), each Definition object has a list of its Arguments and Parameters. This code works fine:

private void BindDefinitions()
        {
            definitionsComboBox.DataSource = definitions;
            argumentsComboBox.DataBindings.Add("DataSource", definitions, "Arguments");
            parametersComboBox.DataBindings.Add("DataSource", definitions, "Parameters");
        }

Somewhere else I've got a list of Validation objects (validations), each Validation object has a Dictionary of its Arguments and a Dictionary of Parameters. Why is the following code not working?

validationsListBox.DataSource = validations;
        argumentsDataGridView.DataBindings.Add("DataSource", validations, "Arguments");
        parametersDataGridView.DataBindings.Add("DataSource", validations, "Parameters");

Edit: the point is to make data displayed in dataGridViews dependent on selected item in validationsListBox

2009-06-16 07:42
by agnieszka


2

I've found such an answer: "You can't bind a dictionary to a DataGridView because the DataGridView.DataSource needs an object that implements IList, IListSource, IBindingList, or IBindingListView.". this is probably the reason.

2009-06-16 08:21
by agnieszka
d'oh! I missed the word "dictionary" in the question. Yup - you can't do that - Marc Gravell 2009-06-16 08:22