c# - 将搜索和排序功能添加到数据绑定(bind)包装器

标签 c# data-binding arcgis arcobjects

我正在使用 C# wrapper of ITable object (ESRI ArcObject Table) ,但是这个包装器缺少排序和搜索功能。有没有办法添加这些功能?我该怎么做?

最佳答案

我可以想到两种方法来尝试这个。两者都需要您创建一个派生自 TableWrapper 的新类.

1. 第一个选项是简单地公开 Items TableWrapper 的属性(继承自 BindingList<IRow> )。完成后,您可以使用 System.Linq获取项目的排序版本,或搜索项目。如果您需要监听 ListChanged 事件,这可能适用于您的场景。

public class GeoGeekTable : TableWrapper 
{
    public IList<IRow> GetTableItems()
    {
        return this.Items;
    } 
}

2. 更长的路线是提供更完整的 BindingList<T> 实现通过创建一个继承自 TableWrapper 的类并实现 TableWrapper 中缺失的继承方法.

BindingList<T>定义了这些方法:

ApplySortCore: Sorts the items if overridden in a derived class; otherwise, throws a NotSupportedException.

FindCore : Searches for the index of the item that has the specified property descriptor with the specified value, if searching is implemented in a derived class; otherwise, a NotSupportedException.

http://msdn.microsoft.com/en-us/library/ms132690.aspx

public class GeoGeekTable : TableWrapper
{
    protected override void ApplySortCore(PropertyDescriptor prop, ListSortDirection direction)
    {
        // see http://social.msdn.microsoft.com/Forums/en-US/csharplanguage/thread/22693b0e-8637-4734-973e-abbc72065969/
    }
}

我希望这能帮助您入门。如果您搜索“override ApplySortCore c#”,您应该获得一些关于实现该方法的指导,因为它是标准的 .NET

关于c# - 将搜索和排序功能添加到数据绑定(bind)包装器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11654074/

相关文章:

c# - 使用 MVVM 绑定(bind) ComboBox SelectedItem

c# - 将存储在对象中的 Enum 数据绑定(bind)到 Winforms ComboBox 中?

python - ArcGIS中栅格属性表制作问题

python-2.7 - 作为独立脚本运行时如何使用 arcpy.GetParameterAsText 更改 python 脚本?

c# - 无法访问派生类中的 protected 方法

javascript - 尝试使用隐藏字段将值从 Javascript 发送到 C#

c# - 如何以编程方式更改谷歌网站翻译器中的语言?

c# - DataBinding 和 ErrorProvider - 如何提供自定义错误消息?

c# - crypt SHA-512 算法的说明 (c#)

python - 启动 python 子进程有不同的行为,具体取决于启动器