I've got a data bound detail form. That I want to dual use for a) listing all items, b) filtering to single set of items.
So the form has these items, an autogen ID (aID), another ID (bID) and some other data fields.
I've added a constructor overload to pass in the bID value, and I've added a query to the TableAdapter on the DataSet for this table, that returns values by that ID.
All that works, if I enter the data direct into to the table for example.
But if the user wants to enter a new record (using the add button of the BindingNavigator) I want to pre-fill the bID field with the value that was passed to form (if there was one), and then set that field to readonly so they can't bork things up.
But I just can't get it to work. I've tried the AddingNew, the CurrentChanged and the CurrentItemChanged events of the BindingSource...but none work. i.e. I've got:
serverIDTextBox.ReadOnly = false;
if (serverID != null)
serverIDTextBox.Text = serverID.ToString();
serverIDTextBox.ReadOnly = true;
in those events currently.
Ah just found, that if I've got data relating to bID already in the table, then everything works! If there are no records for bID then it doesn't:(