Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Studio
  4. DataGridViewComboboxColumn not selecting the right item

DataGridViewComboboxColumn not selecting the right item

Scheduled Pinned Locked Moved Visual Studio
helpcssquestion
1 Posts 1 Posters 10 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    dragon52
    wrote on last edited by
    #1

    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;

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups