Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 377889
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T14:44:24+00:00 2026-05-12T14:44:24+00:00

I have a DataGridView with two DataGridViewComboBoxColumns. I want to use the selected item

  • 0

I have a DataGridView with two DataGridViewComboBoxColumns. I want to use the selected item in the first column to trigger a re-population of the items in the second column, on a per-row basis.

Here’s the code I have so far. “addlInfoParentCat” identifies the first column, and currentRow.Cells.Item(1) is the DataGridViewComboBoxCell that I want to re-populate. ExtEventAdditionalInfoType is a type I defined that contains the string/value pairs.

Private Sub dgvAdditionalInfo_CellValueChanged(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellEventArgs) Handles dgvAdditionalInfo.CellValueChanged
    Dim currentCell As DataGridViewCell
    currentCell = Me.dgvAdditionalInfo.CurrentCell
    If Not currentCell Is Nothing Then
        If currentCell.OwningColumn.DataPropertyName = "addlInfoParentCat" Then
            Dim parentTypeID As Integer = currentCell.Value

            Dim currentRow As DataGridViewRow = Me.dgvAdditionalInfo.CurrentRow
            Dim subtypeCell As DataGridViewComboBoxCell = currentRow.Cells.Item(1)

            Dim theChildren As New List(Of ExtEventAdditionalInfoType)

            theChildren = Custom_ExtEventAdditionalInfoType.GetChildrenOfThisParentOrderByTypeName(parentTypeID)
            subtypeCell.DataSource = Nothing
            subtypeCell.DataSource = theChildren
            subtypeCell.DisplayMember = "ExtEventAdditionalInfoTypeDescr"
            subtypeCell.ValueMember = "ID_ExtEventAdditionalInfoType"
        End If
    End If
End Sub

Basically what I see is that the binding works great the first time around. When I select a item in the first column, it populates the items correctly in the second. I can add rows to the DataGridView and repeat the process.

The problem comes when I try to change the first-column item after the second column has already been bound. I get an endless string of dialog boxes with the following:

System.ArgumentException: DataGridViewComboBoxCell value is not valid.

Any idea why this is happening? Thanks in advance!

UPDATE CodeByMoonlight’s suggestion appears to work.

I clear the DataGridViewComboBoxCell’s value before re-binding:

....

            subtypeCell.DataSource = Nothing
            subtypeCell.Value = Nothing  'here's the change
            subtypeCell.DataSource = theChildren

....
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-12T14:44:25+00:00Added an answer on May 12, 2026 at 2:44 pm

    Well, it looks like as soon as you remodify the first combo’s value, you’re invalidating the binding and datasource you used to populate the second combo, causing all the errors.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have datagridview with checkbox column, but I want, that some of the columns
I have a DataGridView containing two columns. What I want columns to behave is,
I currently have a 2-column wide DataGridView, the first column being a DataGridViewTextBoxColumn and
In my Windows Forms Application, basically I have two DataGridView s. I want to
I have a DataGridView with two columns member name and member image. I want
I have two DataGirdViews. I want to select rows from right DataGridView and pass
I have a DataGridView bound to a LINQ to SQL query expression. I want
I have a datagridview made up of multiple rows and columns. I want to
I have a DataGridView control with two columns. The default color of the text
How do I sort a DataGridView by two columns (ascending)? I have two columns:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.