I request your kind cooperation with the following, I have a student class and a form with 2 textbox, in the load of the form I declare the DataBindings property of each textbox with the attributes of the class, however when setting an attribute of the class , the value in the textbox or visverza object is not updated.
public class alumno : INotifyPropertyChanged
{
private string _nombre;
private string _apellido;
public event PropertyChangedEventHandler PropertyChanged;
public string Nombre { get {return _nombre;} set { _nombre=value; NotifyPropertyChanged();}
public string Apellido { get {return _apellido;} set { _apellido=value; NotifyPropertyChanged();}
private void NotifyPropertyChanged([CallerMemberName] String propertyName = "")
{
PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
}
private void FrmPptoIndRed_Load(object sender, EventArgs e)
{
txtNombre.DataBindings.Add("Text", _alumno, "Nombre");
txtApellido.DataBindings.Add("Text", _alumno, "Apellido");
_alumno.Nombre = "Pedro"; //no actualiza el textbox
txtApellido.Text = "Picapiedra"; //no actualiza el atributo de la clase _alumno.Apellido
}
I do not know what I am doing wrong or what is missing. Thanks.