PC Review


Reply
Thread Tools Rate Thread

DataBinding problem

 
 
Martin
Guest
Posts: n/a
 
      25th Nov 2005
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");

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?


 
Reply With Quote
 
 
 
 
Bart Mermuys
Guest
Posts: n/a
 
      26th Nov 2005
Hi,

"Martin" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?
>



 
Reply With Quote
 
Martin
Guest
Posts: n/a
 
      27th Nov 2005
Thanks, now it works.


"Bart Mermuys" <(E-Mail Removed)> schrieb im Newsbeitrag
news:(E-Mail Removed)...
> Hi,
>
> "Martin" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
>> 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?
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Databinding expressions are only supported on objects that have a DataBinding event jobs Microsoft ASP .NET 0 26th Sep 2007 12:54 AM
Databinding Problem =?Utf-8?B?Q2hyaXM=?= Microsoft ADO .NET 0 29th Mar 2006 02:51 PM
DataBinding Problem Martin Microsoft Dot NET Framework Forms 1 24th Jan 2006 03:39 PM
Databinding Bible (REPOST FROM m.p.d.f.WindowsForms.Databinding) a Microsoft ADO .NET 1 16th Jul 2004 03:26 AM
DataBinding problem Massimo Zaccarin Microsoft Dot NET Framework Forms 2 2nd Apr 2004 03:36 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:07 PM.