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 7499191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:44:21+00:00 2026-05-29T19:44:21+00:00

I have a DataGridView (called DataGridViewSecurity) in VB.net (Visual Studio 2010) which is bound

  • 0

I have a DataGridView (called DataGridViewSecurity) in VB.net (Visual Studio 2010) which is bound to a DataTable (called DataTableSecurity) in a DataSet (called DataSetSecurity). I have added a nonbound column (called nSecurityComboBox) that I set based on an integer field (called nSecLevel) in the DataTable. After setting the combobox, it doesn’t display anything in the combobox, but when you select the combobox, the 5 values in it’s items collection show.

Here’s the code I’m using to add a record to the DataTable and then to set the combobox:

Sub Foo()
.
.
.
    DataSetSecurity.Tables(0).Rows.Add(New Object() {sName, sID, sSec})
    ComboCell_Select(nRow, 3, DataGridViewSecurity, sSecRecs.nSecLevel)
    MessageBox.Show("Value for the combo set at " + DataGridViewSecurity.Rows(nRow).Cells(3).Value.ToString)
.
.
.
End Sub

Private Sub ComboCell_Select(ByVal dgvRow As Integer, _
                             ByVal dgvCol As Integer, _
                             ByRef DGV As DataGridView,
                             ByRef nComboBoxRow As Int16)

    Try
        Dim CBox As DataGridViewComboBoxCell = CType(DGV.Rows(dgvRow).Cells(dgvCol), DataGridViewComboBoxCell)
        Dim CCol As DataGridViewComboBoxColumn = CType(DGV.Columns(dgvCol), DataGridViewComboBoxColumn)

        CBox.Value = CCol.Items(nComboBoxRow)
        DGV.UpdateCellValue(dgvCol, dgvRow)

        'MessageBox.Show("New value in the combo box = " + CBox.Value.ToString)
    Catch ex As Exception
        MessageBox.Show(ex.Message)
    End Try
End Sub

The messagebox.show in Foo shows the correct value for the combobox, but nothing is displayed.
Anyone see what I’m doing wrong?

Thanks.

-NCGrimbo

  • 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-29T19:44:23+00:00Added an answer on May 29, 2026 at 7:44 pm

    In the end, I found some C# code that I converted to VB.net to fix the issue. Here’s the code:

    Private Sub DataGridViewSecurity_EditingControlShowing(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewEditingControlShowingEventArgs) Handles DataGridViewSecurity.EditingControlShowing
        Dim cellComboBox As ComboBox = TryCast(e.Control, ComboBox)
        If cellComboBox IsNot Nothing Then
            ' make sure the handler doen't get registered twice
            RemoveHandler cellComboBox.SelectionChangeCommitted, AddressOf Me.CellComboBoxOnSelectionChangeCommitted
            AddHandler cellComboBox.SelectionChangeCommitted, AddressOf Me.CellComboBoxOnSelectionChangeCommitted
        End If
    End Sub
    
    Private Sub CellComboBoxOnSelectionChangeCommitted(ByVal sender As Object, ByVal e As EventArgs)
        Dim comboBox As DataGridViewComboBoxEditingControl = TryCast(sender, DataGridViewComboBoxEditingControl)
        If sender Is Nothing Then
            Return
        End If
        If comboBox.SelectedItem Is Nothing Then
            Return
        End If
        If Me.DataGridViewSecurity.CurrentCell.Value = comboBox.SelectedItem Then
            Return
        End If
    
        Me.DataGridViewSecurity.CurrentCell.Value = comboBox.SelectedItem
    
    End Sub
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a DataGridView that is bound to a list of objects called BaseChange.
I have a datagridview which im binding DataTable to. What I want do is
I have a dataGridView that has a column called Date Due which is of
I have a BindingList<T> which is bound to a datagridview. One property in my
I have a DataGridView bound to a DataTable. The DataTable is populated from a
I have a Datagridview which populates caller number and called number, upon selecting the
I have a DataGridView and handle event CellFormatting. It has a parameter called: DataGridViewCellFormattingEventArgs
I have a datagridview where the users can select which subset of columns to
I am using vb.net. I have a datagridview to show data. Since the datagridview
I have DataGridView and DataTable with my players. DataTable dt = Extensions.ToDataTable<Player>(PlayerList); Grid.DataSource =

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.