Data binding a combo from the datagrid

E

Earl

I'm trying to get dual-use out of some controls on one form. Essentially I'm
trying to edit the datagrid without either doing an edit within the grid
itself or populating a new form with those values.

The problem is with the combo, since its text value is in a lookup table by
ID. In the initial instance, the combo is bound to an array list. The
displaymember property provides the text. When I save the form values, this
populates the datagrid with a row of all these values. So far, so good.

When the user clicks on a row of the datagrid, I use the currency manager to
bind the values in the datagrid row back to the text boxes and combos (on
the same form) from whence they originated. One of the values I want to
re-populate is the combo text (no problem with the text boxes and dt
picker). However, instead, I get the ID (which is of course correct, since
it is the actual value in the table). I need to translate the binding of
the ID back to the actual text value that the ID selects (note that these
values will be used to Update the grid values).

Dim drvDetail As DataRowView
Dim vueDetail As DataView

Me.BindingContext(vueDetail).Position = cmSupply.Position

cmbSuppliers.DataBindings.clear
.............
'need to convert the ID to the actual name
cmbSuppliers.DataBindings.Add("Text", vueDetail, "SupplierID")
 
K

Kevin Yu [MSFT]

Hi Earl,

I'm not quite sure about your question. I know that you are trying to get
the value back from DataGrid to ComboBox when the selected row changed. But
not quite sure about the detail and the problem. Could you explain it again?

Generally, the binding problems can be caused by a incorrect data source
and data memeber. Please check the data source parameter when getting the
BindingContext to see if it is the same when setting the data source to
DataGrid or ComboBox.

HTH. If anything is unclear, please feel free to reply to the post.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top