JaedenRuiner
Well-known member
- Joined
- Aug 13, 2007
- Messages
- 340
- Programming Experience
- 10+
this one is strange, and frankly I don't know if anyone will be able to help given the complexity of the form and situation, but I'll try to describe it as best I can.
I have multiple (7) binding sources, each bound to their own table in a dataset.
Bind_TblList: Is simply bound to the list of tables and is the datasource of a combobox. When that combobox changes selection, I switch my current "view" to the newly selected table.
Bind_Tbls: Is the datasource of a DGV, and when the "View" changes I set the its datasource to the appropriate "table bound" bindingsource.
there is no need to list them all but lets just say two of the binding sources are
Bind_Cust
Bind_Orders
Each Table has a "TabPage" on a TabControl that contains the "Details" view for each Table. On the Orders detail view there is a ComboBox that points back to the Owning Customer, which displays the "name" for the "id" (simply valuemember versus Displaymember). I soon found that when viewing things on the Customer Detail View, switching between records, it updated the Bind_Cust bindingsource, and thus the "values" of the OrderCustomerComboBox were changing, due to the OrderCustomerComboBox's DataSource being set to the same Bind_Cust. Realizing my folly, I thought on how I would resolve this issue, because if I change the Customer Table in the Customer "View" the dataset believes that there have been changes made and effectively updates the Orders Table along with the Customer Table change. Not that I changed the Orders table, but it "thinks" I did because the OrderCustomerComboBox's DataSource changed, and being DataBound to the Orders.CustID field it assigned the value on the end edit. Rather Annoying.
I thought, to myself, that since the OrderCustomerComboBox's DataSource is only there for an "Item List" it had no need of a BindingSource and could be pointed directly to the table.
This worked on the front that no matter which element I select in the Customer View, the Order View is not affected with regards to the OrderCustomerComboBox, and there are no more data glitches.
However, when viewing the Customer View and through the combobox switch to the OrdersView an interesting thing happens. The SelectView() method tells the "DetailsViewTabControl" to "select" the appropriate TabPage, which in this case is TabOrders, but when it does this, the first control on the TabPage (OrderIDTextBox) is Activated and thus receives the focus, however, the OrderCustomerComboBox's Text is Completely Selected. I deselect all the text and switch back to the Customer View and then back to the Order View and the ComboBox is selected again, even though the focus is in the ID TextBox prior to it in the TabOrder.
Any Idea why using a direct link to the "DataTable" would cause this effect on the selection of a control's text when switching between different Tab Pages Programmatically?
Thanks
I have multiple (7) binding sources, each bound to their own table in a dataset.
Bind_TblList: Is simply bound to the list of tables and is the datasource of a combobox. When that combobox changes selection, I switch my current "view" to the newly selected table.
Bind_Tbls: Is the datasource of a DGV, and when the "View" changes I set the its datasource to the appropriate "table bound" bindingsource.
there is no need to list them all but lets just say two of the binding sources are
Bind_Cust
Bind_Orders
Each Table has a "TabPage" on a TabControl that contains the "Details" view for each Table. On the Orders detail view there is a ComboBox that points back to the Owning Customer, which displays the "name" for the "id" (simply valuemember versus Displaymember). I soon found that when viewing things on the Customer Detail View, switching between records, it updated the Bind_Cust bindingsource, and thus the "values" of the OrderCustomerComboBox were changing, due to the OrderCustomerComboBox's DataSource being set to the same Bind_Cust. Realizing my folly, I thought on how I would resolve this issue, because if I change the Customer Table in the Customer "View" the dataset believes that there have been changes made and effectively updates the Orders Table along with the Customer Table change. Not that I changed the Orders table, but it "thinks" I did because the OrderCustomerComboBox's DataSource changed, and being DataBound to the Orders.CustID field it assigned the value on the end edit. Rather Annoying.
I thought, to myself, that since the OrderCustomerComboBox's DataSource is only there for an "Item List" it had no need of a BindingSource and could be pointed directly to the table.
VB.NET:
[u]Old Way[/u]
Bind_cust.DataSource = myDataSet
Bind_Cust.Datamember = "CustTable"
Bind_Order.DataSource = myDataSet
Bind_Order.Datamember = "OrderTable"
OrderCustomerCombBox.DataSource = bind_cust
OrderCustomerCombBox.DisplayMember = "name"
OrderCustomerCombBox.ValueMember = "id"
[u]New Way[/u]
OrderCustomerCombBox.DataSource = myDataSet.CustTable
OrderCustomerCombBox.DisplayMember = "name"
OrderCustomerCombBox.ValueMember = "id"
This worked on the front that no matter which element I select in the Customer View, the Order View is not affected with regards to the OrderCustomerComboBox, and there are no more data glitches.
However, when viewing the Customer View and through the combobox switch to the OrdersView an interesting thing happens. The SelectView() method tells the "DetailsViewTabControl" to "select" the appropriate TabPage, which in this case is TabOrders, but when it does this, the first control on the TabPage (OrderIDTextBox) is Activated and thus receives the focus, however, the OrderCustomerComboBox's Text is Completely Selected. I deselect all the text and switch back to the Customer View and then back to the Order View and the ComboBox is selected again, even though the focus is in the ID TextBox prior to it in the TabOrder.
Any Idea why using a direct link to the "DataTable" would cause this effect on the selection of a control's text when switching between different Tab Pages Programmatically?
Thanks