IBindingList with dynamic columns

D

Dante

Hi Folks,

I have a datagrid that could be bound to an IBindingList. Currently I
don't get it how the mapping is made between the class and the grid. As
far as I got I have a class with some public properties that will be
mapped automatically by the grid to be used as columns.

Now I have the situation that at runtime it is possible to add some
other objects to that class with a variable amount of entries which
should be shown as columns. Because their can vary I have no properties
for them and have to access them via functions. But how do I get the
grid to understand that?

Thx in advance
 
F

Frans Bouma [C# MVP]

Dante said:
Hi Folks,

I have a datagrid that could be bound to an IBindingList. Currently I
don't get it how the mapping is made between the class and the grid.
As far as I got I have a class with some public properties that will
be mapped automatically by the grid to be used as columns.

Now I have the situation that at runtime it is possible to add some
other objects to that class with a variable amount of entries which
should be shown as columns. Because their can vary I have no
properties for them and have to access them via functions. But how do
I get the grid to understand that?

You've to implement ITypedList. ITypedList allows you to return
propertydescriptors for the properties you want to expose for the
objects IN your collection/list. See for an explanation:

http://weblogs.asp.net/fbouma/articles/115837.aspx

FB

--
------------------------------------------------------------------------
Lead developer of LLBLGen Pro, the productive O/R mapper for .NET
LLBLGen Pro website: http://www.llblgen.com
My .NET blog: http://weblogs.asp.net/fbouma
Microsoft MVP (C#)
------------------------------------------------------------------------
 

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