Hi,
I have a datagridview with a combobox withing a modal form. The combobox shows a list of ingredients where the displaymember is the IngredientName and the valuemember is the IngredientID, and a user would select an ingredient in the combobox and the returning value would be the ID for that ingredient. My issue is that within this same datagridview, i'd like to prepopulate it with items already existing in the database. However i'd like to set the display value in the combobox using the id value from the database. So if "Pasta" was the ingredient name and 101 was the ID, i'd set the value as 101 and it display Pasta in the combobox.
Here's what i have so far:
However doing this shows the ingredientid in the field instead of the ingredientname, but if i go in select the combobox (within the dgv) the ingredients will show, i can select a different ingredient and the ID is returned.
I'm stuck, please help.
I have a datagridview with a combobox withing a modal form. The combobox shows a list of ingredients where the displaymember is the IngredientName and the valuemember is the IngredientID, and a user would select an ingredient in the combobox and the returning value would be the ID for that ingredient. My issue is that within this same datagridview, i'd like to prepopulate it with items already existing in the database. However i'd like to set the display value in the combobox using the id value from the database. So if "Pasta" was the ingredient name and 101 was the ID, i'd set the value as 101 and it display Pasta in the combobox.
Here's what i have so far:
VB.NET:
For Each row As ListViewItem In listIngView.Items
Dim i As Integer = dgvIngEdit.Rows.Add()
dgvIngEdit.Rows(i).Cells(1).Value = row.Text
Next
However doing this shows the ingredientid in the field instead of the ingredientname, but if i go in select the combobox (within the dgv) the ingredients will show, i can select a different ingredient and the ID is returned.
I'm stuck, please help.