Solved

i have problem with comboboxes

Posted on 2004-10-18
4
155 Views
Last Modified: 2010-04-23
Dear Experts,

i need a solution to the above problem.
I have two combobox the first combobox called Periphery and the second called county.
I want to do this : When i select a specified periphery from the first combobox i want the second combobox to give the specified county which belongs to the periphery..

the periphery and county get the fields from the tables from the database..
Please i need help...
0
Comment
Question by:dakanali
4 Comments
 
LVL 10

Accepted Solution

by:
123654789987 earned 25 total points
ID: 12337216
U can see the following link. It shows the relationship between a combobox and a listbox. U can implement the same with two comboboxes

http://codeproject.com/cs/miscctrl/valuemembersample.asp
0
 
LVL 19

Assisted Solution

by:arif_eqbal
arif_eqbal earned 25 total points
ID: 12337321
On SelectedIndexChanged of first ComboBox write the code to populate the other Combo


    Private Sub ComboBox1_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles ComboBox1.SelectedIndexChanged


        Dim DR As OleDbDataReader
        Dim Cn As OleDbConnection = New OleDbConnection(YourConStr)
        Cn.Open()
        Dim Cmd As OleDbCommand = New OleDbCommand("Select YourCol From Yourtable Where AnotherCol='" & ComboBox1.Text & "'", Cn)
        DR = Cmd.ExecuteReader
        Do While DR.Read
            ComboBox2.Items.Add(DR(0))
         Loop

        DR.Close()
        Cn.Close()

End Sub


However this will require a roundtrip to the dataBase so you can as well store all data in a dataTable and locally populate the combobox

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This tutorial demonstrates one way to create an application that runs without any Forms but still has a GUI presence via an Icon in the System Tray. The magic lies in Inheriting from the ApplicationContext Class and passing that to Application.Ru…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now