Setting the BindingSource of several separate controls from one data source at runtime
Posted on 2009-04-26
I have several FlowLayoutPanels on a form that get populated with a control (TextBox) at runtime. All the data is stored in one table but the actual controls are put in different FlowLayoutPanels depending on what category they belong to.
I have imageTableAdapter.FillByPatientID(this.dataSet1.Image) to get me all the record entries for one patient record. For each DataRow in this.dataSet1.Image I create one TextBox control on the form. But I don't know how to set the bindings.
CustomControl[i].txtNotes.DataBindings.Add("Text", this.imageBindingSource, "Notes", true);
If I just keep the above as 'this.imageBindingSource' changing the text of one field changes it for all controls in the form. (The changes are successfully made by the EndEdit() and AcceptChanges() methods btw). How do I know what BindingSource row I should set for each control?
[question re-worded 29/04 to simplify!]