Bound DataGridViewComboBoxCell returning the ValueMember instead of DisplayMember?

I have a DGV that has 2 columns defined as DataGridViewComboBoxCell. One works fine but the other one doesn't. Both column are bound by a BindingSource. The only thing I can think of that is causing the one to act up. Both columns have the "autocomplete" property set to True.

In the column that acts up, whenever I selected a value from the dropdown either by selecting it with a mouse or typing a key and a value appears...as soon as I leave that column, instead of leaving the value in the column, it puts the ValueMember value in place of it. I have no idea why it would do that. My only conclusion would be the way that the SQL Query is structured. I'm using an UNION statement. Not sure about this!

Below is all the code for my DGV.

       
 Private Sub dgvTrans_CellMouseClick(sender As Object, e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles dgvTrans.CellMouseClick
        Try
            Select Case e.ColumnIndex
                Case 8
                    bs.AddNew()
                    bs.MoveLast()
                    dgvTrans.CurrentCell = dgvTrans.Rows(e.RowIndex + 1).Cells(3)
            End Select

        Catch ex As Exception
            Dim strErr As String = "frmTransactions/dgvTrans_CellMouseClick() - " & ex.Message
            MessageBox.Show(strErr, "User Notification", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub
    '
    '
    '
    '
    '
    '
    Private Sub dgvTrans_CellValueChanged(sender As Object, e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvTrans.CellValueChanged
        Try
            If Not blnIsLoading Then
                Select Case e.ColumnIndex
                    Case 3
                        dgvTrans.Rows(e.RowIndex).Cells(4).Value = Now.Date
                End Select
            End If

        Catch ex As Exception
            Dim strErr As String = "frmTransactions/dgvTrans_CellValueChanged() - " & ex.Message
            MessageBox.Show(strErr, "User Notification", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub
    '
    '
    '
    '
    '
    '
    Private Sub dgvTrans_DataError(sender As Object, e As System.Windows.Forms.DataGridViewDataErrorEventArgs) Handles dgvTrans.DataError
        Try

        Catch ex As Exception
            Dim strErr As String = "frmTransactions/dgvTrans_DataError() - " & ex.Message
            MessageBox.Show(strErr, "User Notification", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub
    '
    '
    '
    '
    '
    '
    Private Sub dgvTrans_KeyDown(sender As Object, e As System.Windows.Forms.KeyEventArgs) Handles dgvTrans.KeyDown
        Try
            Dim iRow As DataGridViewRow = dgvTrans.CurrentRow

            Select Case e.KeyCode
                Case 13     'Enter Key was pressed
                    bs.AddNew()                 'Add a new empty Row
                    bs.MoveLast()               'Puts the cursor in the Last Row
                    dgvTrans.CurrentCell = dgvTrans.Rows(iRow.Index + 1).Cells(3)    'Puts the focus on the 1st column
                Case 46     'Delete Key was pressed
                    bs.RemoveAt(iRow.Index)
                Case 120    'F9 Key was pressed
                    bs.AddNew()                 'Add a new empty Row
                    bs.MoveLast()               'Puts the cursor in the Last Row
                    dgvTrans.CurrentCell = dgvTrans.Rows(iRow.Index + 1).Cells(3)    'Puts the focus on the 1st column
            End Select

        Catch ex As Exception
            Dim strErr As String = "frmTransactions/dgvTrans_KeyDown() - " & ex.Message
            MessageBox.Show(strErr, "User Notification", MessageBoxButtons.OK, MessageBoxIcon.Error)
        End Try
    End Sub

Open in new window

BlakeMcKennaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

BlakeMcKennaAuthor Commented:
I actually figured it out. I ended up puting the column that was in the DisplayMember property into the ValueMember property as well. That seemed to work but doesn't seem like the best solution.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NetminderCommented:
I've requested that this question be closed as follows:

Accepted answer: 0 points for BlakeMcKenna's comment #a39476318

for the following reason:

Starting closing process on behalf of Asker.

Netminder
Senior Admin
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.