private void Requery() { _peptides = new BindingList <LinkValue <Peptide> >(Workspace.Peptides.Select(MakeLinkValue).ToList()); peptidesBindingSource.RowSource = BindingListRowSource.Create(_peptides); }
public void TestDataBindingSubList() { var boundDataGridView = new BoundDataGridView { BindingContext = new BindingContext(), DataSource = new BindingListSource(), }; using (boundDataGridView) { var columnIds = new[] { PropertyPath.Root, PropertyPath.Parse("Sequence"), PropertyPath.Parse("AminoAcidsList!*.Code"), PropertyPath.Parse("Molecule!*"), }; var viewSpec = new ViewSpec() .SetColumns(columnIds.Select(id => new ColumnSpec().SetPropertyPath(id))) .SetSublistId(PropertyPath.Parse("AminoAcidsList!*")); var viewInfo = new ViewInfo(new DataSchema(), typeof(LinkValue <Peptide>), viewSpec); // ReSharper disable once UseObjectOrCollectionInitializer var innerList = new BindingList <LinkValue <Peptide> >(); innerList.Add(new LinkValue <Peptide>(new Peptide("AD"), null)); ((BindingListSource)boundDataGridView.DataSource).SetViewContext(new TestViewContext(viewInfo.DataSchema, new[] { new RowSourceInfo(BindingListRowSource.Create(innerList), viewInfo) })); Assert.AreEqual(2, boundDataGridView.Rows.Count); innerList.Add(new LinkValue <Peptide>(new Peptide("TISE"), null)); Assert.AreEqual(6, boundDataGridView.Rows.Count); } }