DatagridView combobox not saving

kahlua001

Contributor
Joined
Dec 15, 2003
Messages
507
Location
los angeles
Hi,
I have a datagridview with a combobox column. the gridview is bound to a datatable as a datasource. The combobox display and value members are set to another datatable so it fills on render and is auto selected based on the row's value. The problem I am having is when I add a new row and select a value from the combobox and then click away from the cell, the value of jumps to a different value, I can't really see a pattern for which value it set to, its just different. Any clues what I'm doing wrong? The list is like 40 items. I have another combobox in the same grid with about 5 values and that works fine. THanks

exItem.DataSource = globals.dtInventoryItems 'This is teh comboxbox
exItem.DataPropertyName = "item_id"
exItem.DisplayMember = "description"
exItem.ValueMember = "item_id"

dgrdvRules.AutoGenerateColumns = False
dgrdvRules.DataSource = globals.dtEventInventoryRules 'This is the datagridview

Its pretty simple, not sure what I'm doing wrong.
 
I think you have a similar problem we faced here.

Basicly you give a property of your class as valuemember, instead of the object itself, so the datagrid tries to save that "Item_ID"-property as an object.
The trick is to change the value member to a property that actually gives the object itself, as described in the thread linked above.

Again all credit goes to whoever wrote this.
 
Back
Top