Re: DataBinding problem by Martin
Martin
Sun Nov 27 06:37:00 CST 2005
Thanks, now it works.
"Bart Mermuys" <bmermuys.nospam@hotmail.com> schrieb im Newsbeitrag
news:uESJN5n8FHA.2036@TK2MSFTNGP14.phx.gbl...
> Hi,
>
> "Martin" <NOSPAM@gmx.de> wrote in message
> news:OTdWDde8FHA.3752@tk2msftngp13.phx.gbl...
>> Hello,
>>
>> i written a collection which holds instances of a specifc class. i added
>> a binding like that
>>
>> textBox1.DataBindings.Add("Text", ((MyClass)oMyCollection[1],
>> "Description");
>
> You are binding to a single object which isn't a problem. But then your
> "object" must have a <PropertyName>Changed event for each property, like:
>
> public class MyClass
> {
> private string name;
>
> public event EventHandler NameChanged;
>
> public string Name
> {
> get
> {
> return name;
> }
> set
> {
> if ( name != value )
> {
> name = value;
> if ( NameChanged != null )
> NameChanged( this, EventArgs.Empty );
> }
> }
> }
> }
>
>
> HTH,
> Greetings
>
>
>
>
>>
>> If the content of the textbox changed, the values are saved in the object
>> of the collection where the controls is bound to. my problem is that
>> other controls don't refresh their data. so if i change the value of a
>> property in my instance. the control still holds the old value. i tried
>> the following:
>>
>> this.BindingContext[((MyClass)oMyCollection[1],
>> "Description"].EndCurrentEdit();
>>
>> but it wasn't the solution. any ideas?
>>
>
>