ITypedList causing my GridStyle to break!

G

Guest

I've got a custom collection called CurrencySummaryTransactionCollection
which is a collection of CurrencySummaryTransaction objects. Each of these
objects has a nested TransactionSummary member called Transactions. I don't
want the DataGrid to display these nested transactions so I've implemented
ITypedList and skipped the Transaction property like this


public PropertyDescriptorCollection GetItemProperties(PropertyDescriptor[]
listAccessors)
{
Type typeOfObject = null;

if( listAccessors==null || listAccessors.Length==0 )
{
typeOfObject = typeof(CurrencyTransactionSummary);
}
else
{
typeOfObject = typeof(CurrencyTransactionSummary);
}

return GetPropertyDescriptors(typeOfObject);

}

private PropertyDescriptorCollection GetPropertyDescriptors(Type
typeOfObject)
{
PropertyDescriptorCollection typePropertiesCollection =
TypeDescriptor.GetProperties(typeOfObject);

ArrayList propertyDescriptorsToUse = new ArrayList();

foreach(PropertyDescriptor property in typePropertiesCollection)
{
if(property.Name == "Transactions")
{
// Don't display this.
}
else
{
propertyDescriptorsToUse.Add(property);
}
}

return new PropertyDescriptorCollection((PropertyDescriptor[])
PropertyDescriptorsToUse.ToArray(typeof(PropertyDescriptor)));
}

However my GridStyle simply isn't applied. Am I missing something fundamental?
 
G

Guest

Hi,

I found the problem. From an example I followed I used this

public string GetListName(PropertyDescriptor[] listAccessors)
{
return "A Typed Collection";
}

so I changed it to

public string GetListName(PropertyDescriptor[] listAccessors)
{
return "CurrencyTransactionSummaryCollection";
}

and lo-and-behold, it's working fine now. Lesson learned!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top