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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T00:58:14+00:00 2026-05-28T00:58:14+00:00

I have a form in my vb.net application used to take the data about

  • 0

I have a form in my vb.net application used to take the data about the returned stock. The form contains two comboboxes. One, named combobox5, contains invoice numbers and the other, named combobox3, contains party codes. Both the comboboxes are pre_loaded using sqldataadapter.

Now what i want is to change the party code in combobox3 when the invoice number is changed in combobox5. Elaborating it further, When Stock is issued the party code is stored along with the invoice number to keep track of to which party was the stock issued. Now when stock is returned i want to keep track that which party has returned the stock and i want that the party code should be automatically selected when the invoice number is changed and it should be what is stored in the database against that particular invoice number….

I’m using the following code for doing so:

    Private Sub ComboBox5_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox5.SelectedIndexChanged

    ' defines a new connection to the database
    Dim con As New SqlConnection("Data Source=TAHA;Initial Catalog=ADT;Integrated Security=True")
    con.Open()


    If ComboBox5.SelectedIndex = 0 Then


        ComboBox3.Enabled = True
        If Not ComboBox3.Items.Count = 0 Then

            ComboBox3.SelectedIndex = 0
        End If
    Else

        Me.ComboBox3.Enabled = False
        Me.ComboBox3.BackColor = Color.White
        Me.ComboBox3.ForeColor = Color.Black

        Dim invoices As New SqlCommand("select invoice_no, party_code from Outgoing_Invoice group by invoice_no, party_code", con)
        Dim reader As SqlDataReader = invoices.ExecuteReader

        While reader.Read

            Dim cnt, i As Integer

            cnt = Me.ComboBox3.Items.Count

            If Me.ComboBox5.SelectedItem.ToString.Trim = reader("invoice_no").ToString.Trim Then

                If Not cnt = 0 Then


                    For i = 0 To cnt - 1
                        If Me.ComboBox3.Items.Item(i).ToString.Trim.Contains(reader("party_code").ToString.Trim) Then   'here i have also used equals instead of contains but that too doesn't work
                            Me.ComboBox3.SelectedIndex = i
                            Exit For
                        End If
                    Next

                End If
            End If
        End While

        reader.Close()



    End If
    con.Close()


End Sub
  • 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-28T00:58:14+00:00Added an answer on May 28, 2026 at 12:58 am

    You want to use the SelectionChangeCommitted event instead because SelectedIndexChanged will also be fired when the selection is changed programmatically.

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

Sidebar

Related Questions

I have application in VB.net that have two different form (Form1 and Form2). Now
I have a windows forms application in .NET 3.5. There's one form with 20
I have a form within an ASP.NET MVC application and I'm trying to submit
Im using c# .net windows form application. i have a SQL database with 5
Im using c# .net windows form application. I have many databases created using sql
Im using c# .net windows form application. I have loaded names of all the
I have a button on an ASP.NET wep application form and when clicked goes
Im using c# .net windows application form. I have created many databases with many
I have a .NET 2.0 WinForms application with a ToolStrip on my main form.
Im using c# .net , windows form application. I have a XML file which

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.