1
Vote

BindingListAdapter does not implement ITypedList - Affects binding to empty set

description

Paul,
 
BindingListAdapter should implement ITypedList in order to allow WinForms DataGridView column binding to succeed when the binding list is initially empty.
 
Code is:
 
    // This method is only used in the design-time framework 
    // and by the obsolete DataGrid control.
    public string GetListName(PropertyDescriptor[] listAccessors)
    {
        return typeof(TElement).Name;
    }
 
    public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[] listAccessors)
    {
        PropertyDescriptorCollection pdc = null;
        if (null == listAccessors)
        {
            pdc = new PropertyDescriptorCollection(_propertyDescriptors.Values.ToArray());
        }
        else
        {
            // Return child list shape.
            pdc = ListBindingHelper.GetListItemProperties(listAccessors[0].PropertyType);
        }
        return pdc;
    }
 
Where ListBindingHelper is in the System.Windows.Forms namespace...
 
Hope this helps,
Andrew.

comments