What voodoo is BindingSource doing?

cjard

Well-known member
Joined
Apr 25, 2006
Messages
7,081
Programming Experience
10+
I have a typed DataRow to which I have added a property. All this property does is return a string. I cannot get a textbox to bind its .Text to this property, and I'm wondering if the bindingsource is the cause of the problem..

Suppose the datarow is just a single column, Column1
i can say in the immediate window:
myDataSet.myDataTable(0). MyProperty
"Hello world"

Now if I try this:
txbx.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataTableBindingSource, "Column1", true));

It works fine.



If I try this:
txbx.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.myDataTableBindingSource, "MyProperty", true));

I get this:
Cannot bind to the property or column MyProperty on the DataSource.
Parameter name: dataMember


Where did it go wrong?
tia!
 
According to a smart cookie on usenet, the IDE/bindingsource/datarowview uses some hidden implementation of the ICustomTypeDescriptor for datarows, rather than standard reflection on the available properties.. That's a nuisance.

Anyone have any ideas where I would find it to subclass or modify it? I suspect it's the DataRowView that the Bindingsource uses, but I would hence struggle to modify it unless I subclass both that an the BindingSource, and then replace the standard BS with my modified ones..

Alternately, I could generate a class that subscribes to the bindingsource PositionChanged event and exposes a collection of bindable properties. That class too could raise propertychanged events when it deems fit...

Or i could just put some code in the .PositionChanged event handler on the form.. Hack hack..
 
Back
Top