Solved

i have problem with comboboxes

Posted on 2004-10-18
4
156 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Since .Net 2.0, Visual Basic has made it easy to create a splash screen and set it via the "Splash Screen" drop down in the Project Properties.  A splash screen set in this manner is automatically created, displayed and closed by the framework itsel…
Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

803 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