DataGridViewComboboxColumn not selecting the right item
-
I am developing an app to manage bank transactions. Each transaction is related to a bank. I display transactions on a Datagridview control. One of the columns is defined as a combobox which contains a list of banks. Each transaction record has an accountID which should select an item in the combobox, ie showing the correct bank for that transaction. What I have done.. 1. The transactions are displayed correctly on the grid; 2. The combobox is loaded with the correct list of banks Problem.. Everything is working fine except the combobox does not show the correct bank for each transaction (ie, no item selected) Not sure the fact that I have 2 data tables is the problem. A table to load the transaction grid. Another table to load the combobox. Both data tables have a column called "account_id". Do I need to do anything else? Here is my code below Any help would be appreciated My grid is called "TransDataGridView" This code loads the combobox using data table dt_Accounts
DataGridViewComboBoxColumn accountsComboboxColumn = (DataGridViewComboBoxColumn)TransDataGridView.Columns["Account"];
accountsComboboxColumn.DisplayMember = "xaccountname";
accountsComboboxColumn.ValueMember = "xaccountid";
accountsComboboxColumn.DataSource = dt_Accounts;This code loads the datagrid using data table dt_Trans
TransDataGridView.DataSource = dt_Trans;