1
I got a class like that:
public class Foo {
#region Construtor
public Foo() { }
#endregion
#region Propriedades
public virtual int? Id { get; set; }
public virtual string Description { get; set; }
public virtual Bar Bar { get; set; }
#endregion
}
and another:
public class Bar {
#region Construtor
public Bar() { }
public Bar(int id, string descricao) {
this.Id = id;
this.Description = descricao;
}
#endregion
#region Propriedades
public virtual int? Id { get; set; }
public virtual string Description { get; set; }
#endregion
}
I am performing inputs Binding as an example below:
private void Form2_Load(object sender, EventArgs e) {
Foo foo = new Foo();
foo.Id = 1;
foo.Description = "Description foo";
foo.Bar = new Bar(2, "Bar item 1");
bindingSource.DataSource = foo;
// Aqui o binding da descrição da classe Foo
textBoxFoo.DataBindings.Add("TEXT", bindingSource, "Description", true, DataSourceUpdateMode.OnPropertyChanged, string.Empty);
// Aqui o binding da descrição da classe Bar
textBoxBar.DataBindings.Add("TEXT", bindingSource, "Bar.Description", true, DataSourceUpdateMode.OnPropertyChanged, string.Empty);
}
When I change the input representing the Foo class description the Currentitemchanged Bindingsource event is called correctly, but when I change the input representing the Bar class description the event is not called. Could someone explain to me why this happens? How I will work with a model similar to this one?