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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:24:09+00:00 2026-06-01T06:24:09+00:00

I have a WinForms app built with VB.Net in VS 2010, and I’m scratching

  • 0

I have a WinForms app built with VB.Net in VS 2010, and I’m scratching my head over the following issue.

I have a form with a combobox which gets bound to a datasource when the form is loaded:

 With Me.cboCompany
    .DataBindings.Clear()
    .DataSource = Me.m_dsBidResults.Tables("Company")
    .ValueMember = "company_id"
    .DisplayMember = "company_name"
    .DataBindings.Add("SelectedValue", Me.m_dsBidResults, Company.company_id")
 End With

I’m using the cboCompany.SelectionChangeCommitted event to filter a datagridview by the selected company ID:

Private Sub cboCompany_SelectionChangeCommitted(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cboCompany.SelectionChangeCommitted
    Dim intCompanyIDN As Integer        
    intCompanyIDN = CInt(cboCompany.SelectedValue)
    SelectBidder(intCompanyIDN)  ' sub to filter datagridview, update labels      
End Sub

This seems to work fine, as long as the user doesn’t switch focus to some other control and then go back to the combobox. After switching focus, if the user then changes the combobox selection to the first item in the dropdown list (SelectedIndex = 0), the SelectionChangeCommitted event fires, but the SelectedValue remains set to the previously selected value. I’ve verified this by adding a message box in the above event handler, displaying SelectedIndex and SelectedValue side-by-side.

'add this to SelectionChangeCommitted event handler
MsgBox(String.Format("Selected Index: {0}, Selected Value: {1}", cboCompany.SelectedIndex, cboCompany.SelectedValue))

This does NOT happen if the user changes SelectedIndex to anything other than 0; everything behaves as expected. I’ve verified that the table I’m binding to contains unique values for company_id and company_name.

Do I need to use some other event to verify that the SelectedValue has actually changed? Alternatively, ideas for a reliable workaround would be welcome.

  • 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-06-01T06:24:11+00:00Added an answer on June 1, 2026 at 6:24 am

    Remove this line from your form and try again

    .DataBindings.Add("SelectedValue", Me.m_dsBidResults, Company.company_id")
    

    Explanantion:
    This code told the combobx that its SelectedValue-property should be bound to the company_id of the dataset. Which is useless, because you already added a list by setting the datasource and you said what the valuemember and displaymember are. Then you implemented your own logic on what it should do when the value changes by using the SelectionChangeCommitted event.
    The extra line that you removed is only usefull if you have another bound object, say of type Person which has a property that shows in what company he works. In that scenario, when the combobox changes, you want the select company_id to be pushed to the Person-object. Something like

    personBindingsource1.DataSource = somePerson;
    cboCompany.DataBindings.Add("SelectedValue", personBindingsource1, "WorksAtCompany")
    

    Hopefully it makes some more sense now 🙂

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

Sidebar

Related Questions

Suppose I have a WinForms app that is built and compiled against .NET 2.0
I have a form in my winforms app that acts as a built-in browser.
I have built a C#.NET WinForms App. I now need to build a MSI
I have a winforms app and the main (and only) form has several buttons.
We have a large WinForms app, and there is a built-in bug reporting system
At work we currently have a custom in-house built winforms app for the business
I have a WinForms app built using Visual Studio 2005, including the crystal reports
I have created a setup project in VS2008. My WinForms app uses .NET 2.0,
I have a windows forms app built with .NET 3.5 and a relatively old
I have a WinForms .NET app that, according to the Vista Task Manager with

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.