So, how do you do it? I bound a few text boxes to an entity type (I have AlphaEntity class with LastName, FirstName properties which I bound to those text boxes), then after initialization, I assigned the datasource of my binding source to an acutal entity object. It did not work, here is my code:
m_AlphaEntity = new AlphaEntity(hAlpha);
if (m_AlphaEntity.IsNew)
throw new System.ApplicationException("The hAlphaKey " + hAlpha.ToString() + " not found.");
// bind the controls on the form:
this.alphaEntityBindingSource.DataSource = m_AlphaEntity;
// adding the following code did not help to display the LastName and the FirstName of the current m_AlphaEntity either:
this.alphaEntityBindingSource.ResetBindings(true);
this.alphaEntityBindingSource.ResetCurrentItem();
this.alphaEntityBindingSource.MoveFirst();
// Here is what the designer did inside the InitializeComponent():
this.alphaEntityBindingSource.DataSource = typeof(Data911.Booking.EntityClasses.AlphaEntity);
this.lastNameTextBox.DataBindings.Add(new System.Windows.Forms.Binding("Text", this.alphaEntityBindingSource, "LastName", true));
Thanks.