Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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.

  • 4 years later...
Posted

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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...