Hi,
I have a Class A which implements bindinglist<B> and ITypedList ( returns propertydescriptorcollection) and am using it as a datasource for grid. Internally i use propertydescriptors which allows user's to add new columns dynamically to the grid.If user' decides to rename the newly added customproperty, how can i do that? and what is the ideal way of doing that?
I am trying to implement by renaming the property in my underlying object which in turn shoud reflect in the grid when it queries property descriptor collection. It partly works when there is no data for that column and i can rename as many times i want. But when i type some value on the column and then i try to rename the property, It throws me a runtime exception ( index out of range in cell collection) where grid can't load .So i am guessing am not follwing the right approach.
I really appreciate ur suggestions.
Thanks,
Valliappan
If you change the name of on of your properties, I don't think the IBindingList implementation has any way of knowing that this occurred and therefore it cannot notify the grid that this happened.
You probably have to fire off a ListChanged notification on your BindingList for PropertyDescriptiorChanged. You will also need to do this for PropertyDescriptorAdded and PropertyDescriptorRemove when you add or remove properties.
Hi Mike,
I do fire listchanged notification in the binding list , but when it tries to rebind it throws the index out of range exception and the grid is unable to redraw itself. This happens when i hv data in that column and trying to rename. How shd i do when i have data in that column and i want to rename?
( As a work around , i used 2 properties for dynamic columns in my object and 1 as KEY and 1 as CAPTION and that solves this problem since i rename only the caption property BUT in th ultracalc manager u mentioned it can't display column CAPTION and there is no way for users to know which key corresponds to which caption once they rename the column)
Hence am trying to figure out if there is a way to rename the column key itself .