In my databound form, I have a combobox for the item's "status". In my test app, I hardcoded a datatable, in reality it would come from the SQL Server
StatusTable = New DataTable
StatusTable.Columns.Add("status", GetType(String))
StatusTable.Rows.Add(New Object() {"New"})
StatusTable.Rows.Add(New Object() {"Printed"})
StatusTable.Rows.Add(New Object() {"Cancelled"})
StatusTable.Rows.Add(New Object() {"Completed"})
So this table gets set as the "DataSource" to my combobox, which is databound onto another table using the following
Status.DataSource = StatusTable
Status.DisplayMember = "status"
Status.ValueMember = "status"
Status.DataBindings.Add("SelectedValue", HeaderTable, "status")
However, if I browse to a record that has the status of "Emailed", I want "Emailed" to be added to the Combobox's options, but only for that record (so no other records can use it, but will preserve past occurances).
Is this possible?
Thanks
Edit:
Using the following code, I can get my "missing" item to appear in the list, but as it's post-binding, it will overwrite my value with a different one
Private Sub Context_CurrentChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Context.CurrentItemChanged
If Not IsDBNull(DirectCast(Context.Current, DataRowView).Item("status")) AndAlso Not StatusTable.Rows.Contains(DirectCast(Context.Current, DataRowView).Item("status")) Then StatusTable.Rows.Add(DirectCast(Context.Current, DataRowView).Item("status"))
Status.DataSource = StatusTable
End Sub
Edit 2:
Here's an attempt at an example:
Table: Status
status
------
New
Printed
Cancelled
Completed
Table: Header
id_num status
-----------------------
1 Completed
2 Cancelled
3 Emailed
4 Printed
5 Printed
6 New
ComboBox's DataSource is bound to Status, and it's "SelectedValue" is DataBound to "Header.status"
So as you move through the Header records, the ComboBox will populate with Completed, Cancelled... and on row 3, it will show nothing (because "Emailed" is not valid in the Status table), however, for historical purposes I would still like to show it without causing any updates to the database.