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. C#
  4. Problems with bound list source for DataGridViewComboBoxColumn

Problems with bound list source for DataGridViewComboBoxColumn

Scheduled Pinned Locked Moved C#
wpfwcfdebugginghelpquestion
2 Posts 1 Posters 0 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.
  • X Offline
    X Offline
    Xpnctoc
    wrote on last edited by
    #1

    I have a data application that is using a DataSet via the designer. I'm trying to create a form that binds data from one table "MyData". One of the fields "picker_fk" uses an FK relationship to a second table "Picker". "Picker" has only one field in it called "descript" (not null, unique). In the form, I set up the DataGridView to use the DataSet.MyData table. For the combo box column, I set the following properties: DataPropertyName = "picker_fk" DataSource = bndPicker (a binding source that uses the "Picker" table from the DataSet) DisplayMember = "descript" ValueMember = "descript" This is all good until I create a new row, select a value from the combo box, and then move focus away. I get a message: SystemArgumentException: Column "descript" is not belong to table "Picker". What's up with that? I'm looking right at the field in the DataSetDesigner. "descript" is the ONE AND ONLY field in "Picker". How can the debugger say it's not in there? I dug around and found a suggestion that this error could occur with data type mismatches. But I have verified that both Picker.descript and the referencing MyData.picker_fk are both of type System.String. Does anyone have any ideas?

    X 1 Reply Last reply
    0
    • X Xpnctoc

      I have a data application that is using a DataSet via the designer. I'm trying to create a form that binds data from one table "MyData". One of the fields "picker_fk" uses an FK relationship to a second table "Picker". "Picker" has only one field in it called "descript" (not null, unique). In the form, I set up the DataGridView to use the DataSet.MyData table. For the combo box column, I set the following properties: DataPropertyName = "picker_fk" DataSource = bndPicker (a binding source that uses the "Picker" table from the DataSet) DisplayMember = "descript" ValueMember = "descript" This is all good until I create a new row, select a value from the combo box, and then move focus away. I get a message: SystemArgumentException: Column "descript" is not belong to table "Picker". What's up with that? I'm looking right at the field in the DataSetDesigner. "descript" is the ONE AND ONLY field in "Picker". How can the debugger say it's not in there? I dug around and found a suggestion that this error could occur with data type mismatches. But I have verified that both Picker.descript and the referencing MyData.picker_fk are both of type System.String. Does anyone have any ideas?

      X Offline
      X Offline
      Xpnctoc
      wrote on last edited by
      #2

      Never mind. I found it. The error message is actually misleading because it doesn't have to do with the names. It has to do with the sequence in which databinding takes place. I set up the BindingSource for the grid BEFORE the BindingSource for the ComboBox options. It's odd that this error was not detected right away but only after adding a row, but I'm not the only one to experience this: http://adamhouldsworth.blogspot.com/2009_04_01_archive.html[^] (Scroll down to the 7 April 2009 entry "Data Binding Pitfall").

      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