mattwilkinson
New member
- Joined
- Jul 31, 2008
- Messages
- 2
- Programming Experience
- 10+
I have a datagridview on which I am displaying several combo boxes. These are databound to a list of items from a DB table.
This is my code I am using to set up the combobox:
I now want to select an item in the list based on the PartDescriptionID e.g.
However this doesn't select the displaymember it just sets the text of the cell to the ID.
How can I specify that I want to select one item in the bound list based on the ID in each
It would be simple if there was a selectedvalue property but one doesn't exist!
This is my code I am using to set up the combobox:
VB.NET:
dgvCombo = New DataGridViewComboBoxColumn
dgvCombo.HeaderText = "Part"
dgvCombo.DisplayMember = "PartDescription"
dgvCombo.ValueMember = "PartDescriptionID"
dgvCombo.DataSource = _dvParts
dgvCombo.MaxDropDownItems = MAXDROPDOWNITEMS
dgvCombo.Width = 250
dgvPaint.Columns.Add(dgvCombo)
I now want to select an item in the list based on the PartDescriptionID e.g.
VB.NET:
For Each dr As DataRow In dt.Rows
dgvPaint.Rows(nRow - 1).Cells(COLPART).Value = dr.Item("psdLinkToPartDescriptionID").ToString
next
However this doesn't select the displaymember it just sets the text of the cell to the ID.
How can I specify that I want to select one item in the bound list based on the ID in each
It would be simple if there was a selectedvalue property but one doesn't exist!