且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

将列表框绑定到绑定列表,对项目属性进行过滤

更新时间:2022-05-22 03:07:40

尝试一下:在您的DataBuilder类中,有一个函数可以根据您的过滤条件返回项的子集.

Try this: in your DataBuilder class, have a function that returns a subset of your items based on your filter condition.

例如,在您的DataBuilder类中:

    public BindingList<TableSet> someTableSets()
    {
        BindingList<TableSet> someTableList = new BindingList<TableSet>();
        foreach (TableSet TS in allTableSets)
            if (TS.IsPopulated == true)
                someTableList.Add(TS);
        return someTableList;
    }

然后,在您的MainForm中,将其设置为等于someTableSets()函数的结果,而不是将DataSource设置为allTableSets:

Then, in your MainForm, instead of setting the DataSource to allTableSets, set it equal to the result of the someTableSets() function:

    this.populatedTableSetsListBox.DataSource = dataBuilder.someTableSets();