Re: Deep databinding - constructing datagrid on the fly
From: Duncan M Gunn (gunnd_at_gaelqualityNOSPAM.co.uk)
Date: 01/26/05
- Previous message: Hemang Shah: "Re: Good Practice on ListBox"
- In reply to: Duncan M Gunn: "Deep databinding - constructing datagrid on the fly"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 26 Jan 2005 14:12:05 -0000
We managed to solve this problem.
The answer lies with PropertyDescriptor objects. Using the example given in
the previous post, ListOfRowObjects should implement IBindingList,
ITypedList. In GetItemProperties(), create a CellPropertyDescriptor object
for each of the columns represented by the list of ColObjects, initialising
the ColumnIndex property of each.
When the datagrid requests data from the ListofRowObjects, it will iterate
over each PropertyDescriptor first, for each RowObject in its list.
CellPropertyDescriptor.GetValue() is called, which is passed the current
RowObject. RowObject.GetValue() can then be called by
CellPropertyDescriptor, and if it is passed the ColumnIndex property then we
have the (x,y) co-ordinate of the cell being rendered in the grid.
RowObject (or ListOfRowObjects could be delegated this responsibility) can
then work out the value which should be returned.
Hope this is of use to someone.
Now I have to find a way of efficiently storing the Cells. I can't just
create a list of Cell objects for each (x,y) position in the grid, as there
will be several empty Cell objects - the ListOfRowObjects can return a
default value when it is asked for a Cell which is empty for a given (x,y)
value - there is no need to actually store an empty Cell object.
Does anyone know of an efficient storage mechanism for a matrix structure
such as this?
Thanks,
Duncan
- Previous message: Hemang Shah: "Re: Good Practice on ListBox"
- In reply to: Duncan M Gunn: "Deep databinding - constructing datagrid on the fly"
- Messages sorted by: [ date ] [ thread ]