I have a typed DataTable with a compound primary key. A BindingSource bsTest is used for binding to controls in a WinForms app:
bsTest.DataSource = dsTest; bsTest.DataMember = dsTest.tblTest.TableName;
The form receives search criteria to select a record, which is done using Linq. Then it is necessary to position bsTest on the selected record. Because of the compound PK, the Find method will not work. I coded a work-around as follows:
var rec = tblTest.FirstOrDefault(<critieria>);<validate rec> // move BindingSource var dv = (DataView)bsTest.List; int n = 0; for (; dv[n].Row != rec; n++); bsTest.Position = n; bsTest.ResetCurrentItem();
There must be a better way to accomplish this, no?